Backup failure in SQL Server 2005 I'm being unable to perform a backup in SQL Server 2005 installed on Windows 7 local machine. I was initially able to do so but as of now, every time I try I get the following message:


  Backup failed for Server 'EBENEZERAKAGLO\SQLEXPRESS'. 
  (Microsoft.SqlServer.Smo)
  
  System.Data.SqlClient.SqlError: Cannot open backup device 'C:\Program
  Files (x86)\Microsoft SQL Server\MSSQL.3\MSSQL\Backup\Naass.bak'.
  Operating system error 5(Access is denied.). (Microsoft.SqlServer.Smo)
Well, suppose you have a command to execute your backup like this

BACKUP DATABASE [naass] 
TO  DISK = N'C:\program files (x86)\Microsoft SQL Server\MSSQL.3\MSSQL\Backup\Naass.bak'' 
WITH NOFORMAT, INIT,  
NAME = N'naas-Complete Database Backup', 
SKIP, NOREWIND, NOUNLOAD,  STATS = 10


this will fail if the process that executes this command doesn't have the permissions to write in the mentioned folder. And Windows 7 (for very good security reasons) keeps the C:\program files folders and its subfolders write locked also to an administrator account.

You could mess with the default permissions and give to your folder above write permissions for your account but of course this is not the recommended way.
Much better, simply change the script to work on a different directory on your disks.

BACKUP DATABASE [naass] 
TO  DISK = N'D:\BackupSQL\naass.bak' 
WITH NOFORMAT, INIT,  
NAME = N'naas-Complete Database Backup'
SKIP, NOREWIND, NOUNLOAD,  STATS = 10


Of course this new directory should have the correct permissions.