78

Can anyone help me, I'm trying to backup a database located on localhost\SQLEXPRESS but i keep getting the following error:

Backup failed for Server 'localhost\SqlExpress'.  (Microsoft.SqlServer.SmoExtended)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=10.0.2531.0+((Katmai_PCU_Main).090329-1045+)&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Backup+Server&LinkId=20476


ADDITIONAL INFORMATION:

System.Data.SqlClient.SqlError: Cannot open backup device 'C:\backup.bak'. Operating system error 5(failed to retrieve text for this error. Reason: 15105). (Microsoft.SqlServer.Smo)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=10.0.2531.0+((Katmai_PCU_Main).090329-1045+)&LinkId=20476

Can anyone explain what I'm doing wrong here ??

thanks

Wesley Wiser
  • 9,491
  • 4
  • 50
  • 69
c11ada
  • 4,302
  • 15
  • 48
  • 62
  • 3
    On Windows 7/2008 saving files to the root of C is not allowed, so if you are running one of these two OS's then this makes sense. – Peter Jul 18 '11 at 18:56
  • 8
    Maybe off topic, but useful to me! – kravits88 Jan 07 '13 at 06:21
  • i had the issue and it was caused by the file already existing. I needed to add code to handle that - and maybe looking for an option in the Backup object (I'm using c# to run the backup in my application) – da Bich Mar 16 '15 at 02:40
  • The earlier comment by Peter worked for me. Reading the backup file from C:\Users\ caused the error whereas moving it to another drive solved the problem. – snowmonkey Apr 24 '15 at 14:15

7 Answers7

89

It looks like the SQL Server doesn't have permission to access file C:\backup.bak. I would check the permissions of the account that is assigned to the SQL Server service account.

As part of the solution, you may want to save your backup files to somewhere other that the root of the C: drive. That might be one reason why you are having permission problems.

Mitch Wheat
  • 295,962
  • 43
  • 465
  • 541
Paul Keister
  • 12,851
  • 5
  • 46
  • 75
45

I've faced this error when there was not enough free space to create a backup.

Jim Simson
  • 2,774
  • 3
  • 22
  • 30
The Smallest
  • 5,713
  • 25
  • 38
15

Assuming that the *.bak file is on the same machine as the SQL Express instance it might be a permissions issue.

If you download procmon http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx you can filter on that file path, look for ACCESS_DENIED errors and if any are there you can see the account name that's failing get to access.

Martin Smith
  • 438,706
  • 87
  • 741
  • 845
  • 2
    I had a completely different problem (not enough disk space) manifesting itself under the same error number - procmon pointed me in the right direction - definately one to remember for the future. Thanks Martin. – Godders Mar 23 '11 at 15:09
  • @Martin: Would it be possible to know how you can find out the error message using ProcMon? – Baahubali Jun 19 '19 at 03:21
10

I got this error too.

The problem turned out to be simply that I had to manually create the full directory structure for the file locations of the MDF & LDF files.

Shame on SQL-Server for not properly reporting the missing directory!

Coder_Dan
  • 1,815
  • 3
  • 23
  • 31
6

I've got the same error. I have been trying to fixing this by setting higher permission to account running SQL Client service, however it didnt help. The problem was that I run MS Sql Management studio just within my account. So, next time... assure that you are running it as Run as Administrator, if using Win7 with UAC enabled.

Jaroslav Urban
  • 1,269
  • 3
  • 20
  • 32
3

I had this error. Nothing worked for me until I opened the SQLServer log file in the "MSSQL10_50" Log folder. That clearly stated which file could not be overwritten. It turned out that the .mdf file was being written into the "MSSQL10" data folder. I made sure that folder had the same SQLServer user permissions as the "MSSQL10_50" equivalent folder. Then it all worked.

The issue here is that the error detail is logged but not reported, so check the logs.

hillstuk
  • 1,576
  • 13
  • 13
3

Yes, it is security issue. Check folder permissions and service account under which SQL server 2008 starts.