Duration of a Database Restore

  • I would like to be able to report on how long a database restore operation took.

    The only information I have been able to find is in the msdb.dbo.restorehistory Table. The Column restore_date is only one value and I don't have a way to calculate the duration.

    I could call getdate() before and after I executed a restore script, as a quick workaround. Has anyone else seen or done something similar to this?

    "Key"
    MCITP: DBA, MCSE, MCTS: SQL 2005, OCP

  • Create a restore job and use it for every restore. Then you'll be able to see the duration in job history. In case you need to keep track of restores over a longer time (not just about the last few restores), copy the data into your table. Job history only saves a limited number of rows for each job.

    Here is how you can get some info about job history (there are more columns, this is just an example - you may add failure messages and other, if you need it). The example works for both SQLS2000 and 2005.

    SELECT job.[name] as JobName, his.step_id, his.step_name, his.run_status,his.run_date, his.run_duration, his.server, step.database_name

    from msdb..sysjobs job

    JOIN msdb..sysjobhistory his ON his.job_id = job.job_id

    JOIN msdb..sysjobsteps step ON step.job_id =his.job_id AND step.step_id=his.step_id

    ORDER BY job.[name], his.step_id

  • Vladan,

    Your technique is exactly what I was looking for. I will work on getting my restore job created, and will post back with results. Thanks for taking the time to reply to my posting!

    "Key"
    MCITP: DBA, MCSE, MCTS: SQL 2005, OCP

  • Vladan,

    I am happy to report that I am now getting the run_duration back in seconds, after scripting the Restore operation to a Job. Thanks again for the suggestion and the query.

    "Key"
    MCITP: DBA, MCSE, MCTS: SQL 2005, OCP

  • Great! Thanks for the feedback, it is good to know that my suggestion helped.

  • was googling for ways to find the duration of a db restore and found this OLD post...

    if you have your errorlog from the time the db was last restored still available you can compare the time in the msdb restorehistory table with the 'recovery complete' entry for that db in the ErrorLog...

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply