A G
A G

Reputation: 22559

sql server Restore Database

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.

Upvotes: 0

Views: 3028

Answers (1)

OMG Ponies
OMG Ponies

Reputation: 332491

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'.

Upvotes: 2

Related Questions