SQL Clone
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Script to determine backup finish times

By lhughes92,

SQL Server provides the RESTORE HEADERONLY command which helps users determine backup completion times.  What if you have the need to use this completion time for comparison, perhaps to set up a job that only restores the file if it is xx hours old.  This script can be used to determine the maximum backup finish date for a particular file.  The script reads this field from the backupset system table in the msdb database.  It then joins to the backupmediafamily table to allow the user to specify the exact physical device location.  Make sure to use the full path to the location of the device.  After this code completes, you can compare @FinishDate to the current date (using GETDATE) to determine if the file should be restored.  These steps can be placed in a SQL Server job, then scheduled for easy administration.

Total article views: 364 | Views in the last 30 days: 1
Related Articles

List database restore COMPLETION datetime

This script shows the COMPLETION datetime of database restore.


Restore log with standby option takes too long to complete!

Restore using "with standby " takes too long to complete


Day 3 of 31 Days of Disaster Recovery: Determining Files to Restore Database

Day 3 of 31 Days of Disaster Recovery: Determining Files to Restore Database 31 Days of Disaster ...


How to Get Estimated Completion Time of SQL Server Database Backup OR Restore

“How much time SQL Server is going to take to complete the database Backup or Restore” – This is one...


Determining a database's completed restore date and time...

I am familiar with the various queries that can be run to return information out of the 'msdb' datab...