Restore Backup Fails - File 'Db' cannot be restored to '{...}.mdf'. Use WITH MOVE to identify a valid location for the file
Take another look at the output from your first command. There is an error messag in it that points you to the fix.
Look for this section:
Use WITH MOVE to identify a valid location for the file.
Basically, the file path on your machine doesn't match the original machine. The MOVE option will let you fix that.
Here is an example of the RESTORE command using the MOVE option:
USE [master]
RESTORE DATABASE [AdventureWorks2008R2]
FROM DISK = N'C:\SQL Backups\AdventureWorks2008R2.bak'
WITH FILE = 1,
MOVE N'AdventureWorks2008R2_Data' TO N'C:\MyNewDataLocation\AdventureWorks2008R2_Data.mdf',
MOVE N'AdventureWorks2008R2_Log' TO N'C:\MyNewLogLocation\AdventureWorks2008R2_Log.ldf',
MOVE N'FileStreamDocuments2008R2' TO N'C:\MyNewFileStreamLocation\Documents2008R2',
NOUNLOAD, REPLACE, STATS = 1
GO
Hope this helps!
Steven's answer worked for me when I executed this command before the RESTORE:
alter database [YourDBName]
set offline with rollback immediate
and this one after the RESTORE:
alter database [YourDBName]
set online