Click here to monitor SSC
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)

T-Log Backup/Restore with Date & Time

By S. Kusen,

Recently, I have been moving a lot of VLDB's onto new SQL Server environments. One method (of many) is to restore the full backup to the new system, and then incrementally restore log backups in sequence.

One way to lessen confusion would be to name the log backups to include the date and time to prevent overwriting the files, and hopefully make it less confusing as you proceed with the DB move, which is what this script tries to accomplish.

What I have been doing for my recent migrations is backup the log every 4 hours, and as I get closer to the maintenance window, I'll lower the frequency down to 1 hour, and then down to 15 minutes; I restore each log on the new system as they are backed up. Using the backup script provided, it will dynamically update the file names as you change the schedule of the SQL Server Agent job. At the time of the cutover, the last 15 minute log backup is quick to restore.

There are obviously ways to automate these scripts even more, but this method has helped me out a lot recently.

To start using this, make sure you've set the database to FULL recovery model and have already taken a full database backup after changing the recovery model, and then restored that backup to your new host.

To use, change the path of the location for your backups, and change YourDBNameHere to the name of your database to backup the log.


As always, thanks for checking out my scripts.




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

Backup & Restoration Script

This script provides very useful information about database backup and restoration.


Generate RESTORE DATABASE Script without Using CMDSHELL

Use this script to generate RESTORE DATABASE scripts for all .BAK backup files from backup location ...


Script to Restore Entire database from a directory

Script to restore the entire databases from the backup directory just by passing the backup director...


Restore script for Ola Hallengren backup

Create a restore script based on backup files in a directory


Script to restore red gate backups automatically from a folder.

Restore of red gate backup files using a SQL Script

backup and restore