[sql-server-2008] Cannot open backup device. Operating System error 5

Below is the query that I am using to backup (create a .bak) my database.

However, whenever I run it, I always get this error message:

Msg 3201, Level 16, State 1, Line 1
Cannot open backup device 'C:\Users\Me\Desktop\Backup\MyDB.Bak'. Operating system error 5(Access is denied.).

Msg 3013, Level 16, State 1, Line 1
BACKUP DATABASE is terminating abnormally.

This is my query:

BACKUP DATABASE AcinsoftDB
TO DISK = 'C:\Users\Me\Desktop\Backup\MyDB.Bak'
WITH FORMAT,
MEDIANAME = 'C_SQLServerBackups',
NAME = 'Full Backup of MyDB';

The answer is


Here is what I did to by-pass the issue.

1) Go to backup

2) Remove the destination file-path to disk

3) Click on Add

4) In the File name: check box manually type in the backup name after ..\backup like below where Yourdb.bak is the database backup name

C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Backup\Yourdb.bak

5) Click on OK

Hope this helps!


I experienced this problem when the .BAK file was temporarily stored in a folder encrypted with BitLocker. It retained the encryption after it was moved to a different folder.

The NETWORK SERVICE account was unable to decrypt the file and gave this thoroughly informative error message.

Removing BitLocker encryption (by unchecking "Encrypt contents to secure data" in the file properties) on the .BAK file resolved the issue.


Go to the SQL server folder in start menu and click configuration tools Select SQL Server configuration manager On SQL server services, on the desired instance change the (Log On as) to local system


I was just going through this myself. I had ensured that my MSSQLSERVER login user had full access but it was still causing issues. It only worked once I moved the destination to the root of C. More importantly out of a user folder (even though I had a share with full permissions - even tried "Everyone" as a test).

I don't know if i consider my issue "fixed", however it is "working".

Just a FYI for any other users that come across this thread.


My issue was that the "File Ownership" was set to my company. I changed it to "Personal" and it worked. Right click the file and click the "File Ownership >" option and then change it to "Personal". I believe this happens with all files sent over Microsoft Teams.


SQL Server is not able to access (write) the backup into the location specified.

First you need to verify the service account on which the Sql server is running. This can be done by using Configuration manager or Services.msc.

or

Use below query :

SELECT  DSS.servicename,
    DSS.startup_type_desc,
    DSS.status_desc,
    DSS.last_startup_time,
    DSS.service_account,
    DSS.is_clustered,
    DSS.cluster_nodename,
    DSS.filename,
    DSS.startup_type,
    DSS.status,
    DSS.process_id FROM    sys.dm_server_services AS DSS;

Now look at the column service_account and note it down.

Go to the location where you are trying to take the backup.In your case : C:\Users\Me\Desktop\Backup

Right click--> Properties --> Security -->

Add the service account and provide read/write permissions. This will resolve the issue.


In my case, I forgot to name the backup file and it kept giving me the same permission error :/

TO DISK N'{path}\WRITE_YOUR_BACKUP_FILENAME_HERE.bak'

Share this folder and use UNC path, by example: \pc\backups\mydb.bak

Then You can stop share.

Not very elegant, but it resolves all permissions problems (You need to give permissions to share as well, as mentioned above)


I have the same error. Following changes helped me to fix this.

I had to check Server Manager->Tool->Services and find the user ("Log On As" column) for service: SQL Server (SQLEXPRESS).

I went to the local folder (C:\Users\Me\Desktop\Backup) and added "NT Service\MSSQL$SQLEXPRESS" as the user to give Write permissions.


I face the same problem with SQL Express 2014 SP1 on Windows 10.

Solution which work

  1. Open Service by typing Services
  2. Locate and open the SQL Server (SQLExpress)
  3. Go to the LogOn Tab
  4. Choose Local System Account ( Also Check for Allow Services to interact with desktop )
  5. Click OK . Stop the service . Restart the service.
  6. Problem solved

In order to find out which user you need to give permission to do the restore process, you can follow the following steps:

You need to go to your server where SQL Server is installed. Find SQL Server Configuration Manager

enter image description here

Next, you need to go to "SQL Server Services"

enter image description here

Under your SQL Server (MSSQLSERVER) instance there will be an account with column "Logon As", in my case it is NT Service\MSSQLSERVER.

That is the account which you need to add under Security tab of your source .bak location and give that user the "Read" permissions so that the backup file can be read.

Let's say your backup file is present at "D:\Shared" folder, then you need to give permissions like this:

enter image description here


The SQL Server service account does not have permissions to write to the folder C:\Users\Kimpoy\Desktop\Backup\


I had this issue recently as well, however I was running the backup job from server A but the database being backed up was on server B to a file share on server C. When the agent on server A tells server B to run a backup t-sql command, its actually the service account that sql is running under on SERVER B that attempts to write the backup to server C.

Just remember, its the service account of the sql server performing the actual BACKUP DATABASE command is what needs privileges on the file system, not the agent.


Hi you need to change the query from:

BACKUP DATABASE AcinsoftDB
TO DISK = 'C:\Users\Me\Desktop\Backup\MyDB.Bak'

to

BACKUP DATABASE AcinsoftDB
TO DISK = N'C:\Users\Me\Desktop\Backup\MyDB.Bak'

You have to add a N in front of the path works for me.


I had a similar issue. I added write permissions to the .bak file itself, and my folder that I was writing the backup to for the NETWORK SERVICE user. To add permissions just right-click what file/directory you want to alter, select the security tab, and add the appropriate users/permissions there.


I know it is not an exact solution but using external drive paths solves this problem.

BACKUP DATABASE AcinsoftDB
TO DISK = 'E:\MyDB.Bak'
WITH FORMAT,
MEDIANAME = 'C_SQLServerBackups',
NAME = 'Full Backup of MyDB';

One of the reason why this happens is you are running your MSSQLSERVER Service not using a local system. To fix this issue, use the following steps.

  1. Open run using Windows + R
  2. Type services.msc and a services dialog will open
  3. Find SQL Server (MSSQLSERVER)
  4. Right click and click on properties.
  5. Go to Log on tab
  6. Select Local System account and click on "Apply" and "OK"
  7. Click on Stop link on the left panel by selecting the "SQL Server (MSSQLSERVER)" and Start it again once completely stopped.
  8. Enjoy your backup.

Hope it helps you well, as it did to me. Cheers!



Please check the access to drives.First create one folder and go to folder properties ,

You may find the security tab ,click on that check whether your user id having the access or not.

if couldn't find the your id,please click the add buttion and give user name with full access.


Msg 3201, Level 16, State 1, Line 1 Cannot open backup device 'C:\Backup\Adventure_20120720_1024AM.trn'. Operating system error 5(Access is denied.). Msg 3013, Level 16, State 1, Line 1 BACKUP LOG is terminating abnormally.

I verified backup folder on C drive, Is new service account is having full control access permission or not?, I realized that "Test\Kiran" service account is not having Full control security permission.

Please follow the below steps to give full control to service account:

  1. Go to C drive, Right click on Backup folder.
  2. Select Security tab.
  3. Click on Edit button, new window will open.
  4. Click on Add button and enter Test\Kiran user account and click check name button, this will validate you entered user is existing or not, if it is existing it will show the user on window, select OK.
  5. Select you entered user name and select Full Control check box under allow.

I solved the same problem with the following 3 steps:

  1. I store my backup file in other folder path that's worked right.
  2. View different of security tab two folders (as below image).
  3. Edit permission in security tab folder that's not worked right.

enter image description here


Examples related to sql-server-2008

Violation of PRIMARY KEY constraint. Cannot insert duplicate key in object How to Use Multiple Columns in Partition By And Ensure No Duplicate Row is Returned SQL Server : How to test if a string has only digit characters Conversion of a varchar data type to a datetime data type resulted in an out-of-range value in SQL query Get last 30 day records from today date in SQL Server How to subtract 30 days from the current date using SQL Server Calculate time difference in minutes in SQL Server SQL Connection Error: System.Data.SqlClient.SqlException (0x80131904) SQL Server Service not available in service list after installation of SQL Server Management Studio How to delete large data of table in SQL without log?

Examples related to backup

input file appears to be a text format dump. Please use psql How can I backup a Docker-container with its data-volumes? Backup/Restore a dockerized PostgreSQL database Export MySQL database using PHP only Tar a directory, but don't store full absolute paths in the archive How to extract or unpack an .ab file (Android Backup file) mysqldump with create database line Postgresql 9.2 pg_dump version mismatch How to backup Sql Database Programmatically in C# Opening a SQL Server .bak file (Not restoring!)

Examples related to access-denied

pip install access denied on Windows Getting "java.nio.file.AccessDeniedException" when trying to write to a folder mysqldump Error 1045 Access denied despite correct passwords etc Hosting ASP.NET in IIS7 gives Access is denied? MySQL ERROR 1045 (28000): Access denied for user 'bill'@'localhost' (using password: YES) Access to the path 'c:\inetpub\wwwroot\myapp\App_Data' is denied Access restriction: Is not accessible due to restriction on required library ..\jre\lib\rt.jar IIS Express gives Access Denied error when debugging ASP.NET MVC Access to the path denied error in C# Unable to copy file - access to the path is denied

Examples related to permission-denied

Error: EACCES: permission denied, access '/usr/local/lib/node_modules' PermissionError: [Errno 13] Permission denied Github permission denied: ssh add agent has no identities WinSCP: Permission denied. Error code: 3 Error message from server: Permission denied Permission denied on accessing host directory in Docker .bashrc: Permission denied C compile error: Id returned 1 exit status Executing a shell script from a PHP script Permission denied on CopyFile in VBS Node.js EACCES error when listening on most ports