1
Vote

Operating system error 5(Access is denied.)

description

when I run the command (expressmaint -S .\WSE -U sa -P !ws1adm -D ALL_USER -T DB -R D:\DatabaseBackup\EBB -RU WEEKS -RV 1 -B D:\DatabaseBackup\EBB -BU DAYS -BV 1
) in cmd, there is no bak file created and the log displays that:
            An exception occurred while executing a Transact-SQL statement or batch.
Cannot open backup device 'D:\DatabaseBackup\Application_FullBackup_20090915_0959.bak'. Operating system error 5(Access is denied.).
BACKUP DATABASE is terminating abnormally.

comments

jaspersmith wrote Sep 15, 2009 at 8:26 PM

Make sure that the SQL Service account has read/write permissions to the D:\DatabaseBackup folder. This error is due to SQL Server not being able to write to the specified file. Note that the SQL Service account is generally different than the account used to Expressmaint but it is that account that SQL Server uses to write backups.

Alovera wrote Mar 31, 2010 at 4:10 PM

I modified the ExpressMaint.vb file to allow the user to specify a local temporary backup folder (using the option -BT <path>) where database backups will be created and verified. This allows the user to create a local directory that has stripped down permissions that allow the SQL Service account (e.g. like Local Service) to write the backup. Once the backup has been created and verified (if specified by -V option), the account used to run ExpressMaint can then move the file to a network location specified as the base backup folder (-B option). This provides a more secure setup than running the SQL Service with a high privilege account that has network access.

You can download the source code from this post or from the Source Code > Patches link (id is 5657).

habeeb_matrix wrote Oct 17, 2012 at 3:21 PM

I had this issue and all the solutions online was kind of misleading to my issue. I have the solution here.
http://dotnet-programming-solutions.blogspot.com/2012/10/attach-database-encountered-operating.html
The solution was to Run SSMS as Administrator.