views:

75

answers:

1

Backed up a database from my hosting account. Using the following script to restore.

RESTORE DATABASE [XYZ] 
FROM  DISK = N'E:\Online Website Backup\_db_backups\XYZ.bak' 
WITH  FILE = 1,  MOVE N'XYZ' TO N'C:\Program Files (x86)\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\XYZ.mdf',  
MOVE N'XYZ_log' TO N'C:\Program Files (x86)\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\XYZ.LDF',  
MOVE N'sysft_XYZ' TO N'C:\Program Files (x86)\Microsoft SQL Server\MSSQL.1\MSSQL\FTData\XYZ',  
NOUNLOAD,  REPLACE,  STATS = 10
GO

Getting the following errors

Msg 3634, Level 16, State 1, Line 1
The operating system returned the error '5(Access is denied.)' while attempting 'OpenForRestore' on 'C:\Program Files (x86)\Microsoft SQL Server\MSSQL.1\MSSQL\FTData\XYZ\SQL.HDR'.
Msg 3156, Level 16, State 2, Line 1
File 'sysft_XYZ' cannot be restored to 'C:\Program Files (x86)\Microsoft SQL Server\MSSQL.1\MSSQL\FTData\XYZ'. Use WITH MOVE to identify a valid location for the file.
Msg 3119, Level 16, State 1, Line 1
Problems were identified while planning for the RESTORE statement. Previous messages provide details.
Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.

Thanks.

+2  A: 

The user account being used doesn't have permissions to the folders/file:

The operating system returned the error '5(Access is denied.)' while attempting 'OpenForRestore' on 'C:\Program Files (x86)\Microsoft SQL Server\MSSQL.1\MSSQL\FTData\XYZ\SQL.HDR'.

OMG Ponies
logged in using windows authentication. It should have access.
Aseem Gautam
@Aseem Gautam: You're logged in, but that's not necessarily the account that is being used to access the backup.
OMG Ponies
Yes thanks, got it. Modified the folders security settings.
Aseem Gautam