Quantcast
Channel: Red Gate forums: SQL Backup 7
Viewing all articles
Browse latest Browse all 713

RE: Using 'master..sqlbackup' to do virtual restore

$
0
0
I am looking to automate doing virtual restores on a number of databases after each nightly backup. The extended sp does this nicely, but it doesnt take advantage of the virtual restore feature -- too bad.

Using native sql then for each database that I want to check, I need something like this:

-- Script generated by Red Gate SQL Virtual Restore v2.4.0.164
-- Multi-threaded SQL Backup backups are handled by repeating the DISK parameter in the RESTORE command, once for each thread used during the backup process.
RESTORE DATABASE [MyDB_Virtual] FROM
DISK=N'D:\SQLBackup\MyDB\MyDB_FULL_20130205201700.sqb',
DISK=N'D:\SQLBackup\MyDB\MyDB_FULL_20130205201700.sqb',
DISK=N'D:\SQLBackup\MyDB\MyDB_FULL_20130205201700.sqb'
WITH MOVE N'MyDB_Data' TO N'F:\SQLBackup\MyDB\MyDB_MyDB_Virtual.vmdf',
MOVE N'MyDB_Log' TO N'F:\SQLBackup\MyDB\MyDB_MyDB_Virtual.vldf',
NORECOVERY, STATS=1
GO
RESTORE DATABASE [MyDB_Virtual] FROM
DISK=N'D:\SQLBackup\MyDB\MyDB_DIFF_20130207220005.sqb',
DISK=N'D:\SQLBackup\MyDB\MyDB_DIFF_20130207220005.sqb',
DISK=N'D:\SQLBackup\MyDB\MyDB_DIFF_20130207220005.sqb'
WITH NORECOVERY, STATS=1
GO
RESTORE DATABASE [MyDB_Virtual] WITH RECOVERY, RESTRICTED_USER
GO
DBCC CHECKDB ([MyDB_Virtual])
GO
DROP DATABASE [MyDB_Virtual]
GO

Obviously, this script changes each night in terms of file names and, if for some reason, the number of threads used changes.

So, is there something available that will generate this sort of sql given a database name and the folder that holds the full+diff backups?

Thanks.

Viewing all articles
Browse latest Browse all 713

Trending Articles