Sql-server – Restore a large number of transaction logs

restoresql serversql-server-2008-r2transaction-log

I'm using SQL Server 2008 R2, and I need to restore 36 .trn logs to a database. I have restored the first 4 using the restore transaction log functionality in SSMS (right-click database > tasks > restore > transaction log).

Is there a way to restore them all in order using this tool or with a script? The .trn files are in a folder on a remote server. I do not not need to restore all the files in the folder, only ones between specific dates.

I'm looking for a way to automate this so I don't have to manually restore each individual log.

I access the files using an address like the one below.

\\remote server IP\SQL_Backup\LMSQL02\TLog\file.trn

Best Answer

I would suggest to use Restore Gene : Automating SQL Server Database Restores - written by Paul Brewer

The Restore Gene stored procedure generates the required restore scripts, including the DBCC CHECKDB command, if required. It is a useful tool, by itself; in disaster recovery situations, it can construct a restore script, in seconds. It optionally includes override options for name of the target database and WITH MOVE overrides for data, log file locations, which might help recover lost data by restoring a temporary version of a database to the same instance.

It has both TSQL and PowerShell versions for automation.