LONG
LONG

Reputation: 4610

Unmatching Database restore path

I am restoring a database in SSMS using command:

RESTORE DATABASE name
FROM DISK = '...' 
WITH REPLACE, STATS =25
(the path is an UNC path)

Before the job runs fine in sql server agent, this job failed just now because of some external reasons, now no matter either I tried to run the query in SSMS command window or the scheduled job in sql server agent, it gives the error message, says:

Directory lookup for the file "D:..." same for the log backup

How the restoring process try to look for the .bak files on 'D'drive instead of the specified UNC path? I double checked all .bak files are there. Why it's trying to look for a different backup path? lol

Upvotes: 0

Views: 415

Answers (1)

TheGameiswar
TheGameiswar

Reputation: 28900

When you backup database,it backups path of its old data files and log files.So when you don't specify restore path,it tries to restore it in old path on current server..

so try to provide explicit naming and use with move option

Example using Adventure works

RESTORE DATABASE AdventureWorks2012  
   FROM AdventureWorksBackups  
   WITH NORECOVERY,   
      MOVE 'AdventureWorks2012_Data' TO   
'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Data\NewAdvWorks.mdf',   
      MOVE 'AdventureWorks2012_Log'   
TO 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Data\NewAdvWorks.ldf';  

Upvotes: 1

Related Questions