Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Duration of a Database Restore Expand / Collapse
Author
Message
Posted Monday, December 10, 2007 11:18 AM
Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Thursday, February 26, 2009 3:02 PM
Points: 515, Visits: 655
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
Post #431454
Posted Tuesday, December 11, 2007 12:42 AM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Thursday, May 5, 2011 1:38 AM
Points: 1,636, Visits: 604
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



Post #431648
Posted Tuesday, December 11, 2007 7:24 AM
Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Thursday, February 26, 2009 3:02 PM
Points: 515, Visits: 655
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
Post #431778
Posted Tuesday, December 11, 2007 8:57 AM
Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Thursday, February 26, 2009 3:02 PM
Points: 515, Visits: 655
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
Post #431847
Posted Wednesday, December 12, 2007 1:00 AM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Thursday, May 5, 2011 1:38 AM
Points: 1,636, Visits: 604
Great! Thanks for the feedback, it is good to know that my suggestion helped.


Post #432163
Posted Friday, August 15, 2014 8:34 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Wednesday, September 3, 2014 9:16 AM
Points: 82, Visits: 295
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...
Post #1603732
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse