New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sp_DatabaseRestore: validate @Database against FULL backup file #1894

ShawnCrocker opened this Issue Dec 14, 2018 · 1 comment


None yet
2 participants
Copy link

ShawnCrocker commented Dec 14, 2018

Version of the script
Commit from Issue 1185

What is the current behavior?
Imagine one of these calls

EXEC _DBA.dbo.sp_DatabaseRestore
@database = 'SomeDB',
@RestoreDatabaseName = 'SomeDBTest'
@BackupPathFull = '\blah\SomeDBCopy',
@MoveFiles = 1,

EXEC _DBA.dbo.sp_DatabaseRestore
@database = 'SomeDB',
@BackupPathFull = '\blah\SomeDBCopy',

SQL Pattern matching means we can restore SomeDBCopy because it matches SomeDB in filters like
BackupFile LIKE N'%' + @database + N'%'
And file moves don't work as expected because of the simple REPLACE

Fixing the LIKE/REPLACE code is possible but we can validate that the full backup files does actually match the @database parameter.

If the current behavior is a bug, please provide the steps to reproduce.
Pick any database naming convention as above

What is the expected behavior?
We restore exactly
Which versions of SQL Server and which OS are affected by this issue? Did this work in previous versions of our procedures?
Tested here on SQL 2012+ 2017 so assum all versions have the same issue


This comment has been minimized.

Copy link

BrentOzar commented Jan 10, 2019

Nice job. Thanks, sir!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment