SQL Server – Steps to Restore Database to a Point in Time

restoresql server

Time given lies in all three backups, full, diff ,log:

  • full – 12 midnight
  • diff – 4 am ( every 4 hours)
  • log – 15 minutes interval

When:

  1. time restore is 5:17
  2. time restore is 5:14

How should I answer that?

Best Answer

I'd answer that from the backupmediafamily and backupset tables. Build the restore T-SQL dynamically from that using STOPAT for the time you want to restore.

Or:

Use PowerShell + dbatools pipe get-backuphistory to restore-database using the -restoretime parameter.