I am trying to use sp_DatabaseRestore
from the SQL Server First Responder Kit to restore some databases. It works fine if I first restore the database in a normal way using SSMS, but if the database does not previously exist, it says that it could not find the file specified (for both data an log-files).
It also ends with the following message:
The database "DatabaseName" does not exist. RESTORE can only create a database when restoring either a full backup or a file backup of the primary file.
But the first path is for the full backup, so I am not sure what this means.
Is there some particular use of the parameters that would help me use this even when the database does not exist, or am I forced to create them first?
Any suggestions appreciated.
Edit: Code that is used (paths and names have been changed). The code fails if the database does not exist. If I create the database, then it works:
DECLARE @VersionDate datetime;
EXEC dbo.sp_DatabaseRestore @Database = N'DatabaseName',
@BackupPathFull = N'\\SERVERNAME\Backup\servername-wfcs$ServerNameAG01\DatabaseName\FULL\',
@BackupPathLog = N'\\SERVERNAME\Backup\servername-wfcs$ServerNameAG01\DatabaseName\LOG\',
@MoveFiles = 0,
@ContinueLogs = 0,
@RunRecovery = 1,
@ForceSimpleRecovery = 0,
@Debug = 0,
@VersionDate = @VersionDate OUTPUT
Edit 2: Turns out there was a difference in the data-file folder names between the old and the new server. The old server had a version-number lower than the actual version of the SQL Server, probably due to an earlier in place upgrade. When trying to restore from a backup with correct data folder, there is no problem.
-
The first googled link has an answer: brentozar.com/archive/2017/03/…Denis Rubashkin– Denis Rubashkin2018年11月06日 12:58:05 +00:00Commented Nov 6, 2018 at 12:58
-
@DenisRubashkin Thanks for your comment. However I have read that documentation already (and once again now), and I can't really find anything there that answers my question. If you found the answer in there, I would appreciate it if you could narrow it down for me where to look in that link.GHauan– GHauan2018年11月06日 13:16:24 +00:00Commented Nov 6, 2018 at 13:16
-
Can you post the command you're using now that isn't working?Erik Reasonable Rates Darling– Erik Reasonable Rates Darling2018年11月06日 13:18:25 +00:00Commented Nov 6, 2018 at 13:18
-
2Specify variables MoveFiles = 1, MoveDataDrive = YourDataLocation and MoveLogDrive = YourLogLocation" - I believe it should helpDenis Rubashkin– Denis Rubashkin2018年11月06日 13:24:13 +00:00Commented Nov 6, 2018 at 13:24
-
@sp_BlitzErik Hi Erik, I edited my post and added the code.GHauan– GHauan2018年11月06日 13:27:33 +00:00Commented Nov 6, 2018 at 13:27
1 Answer 1
Turns out there was a difference in the data-file folder names between the old and the new server. The old server had a version-number lower than the actual version of the SQL Server, probably due to an earlier in place upgrade. When trying to restore from a backup with correct data folder, there is no problem.