Errors when running a scheduled job with SQL Backup Errors when running a scheduled job with SQL Backup

Errors when running a scheduled job with SQL Backup

This article will enable you to deal with these error messages when creating a scheduled job for SQL Backup:

Error 880: BACKUP DATABASE permission denied in database: (XXX) 

SQL error 15157: Setuser failed because of one of the following reasons: the database principal 'XXX'

When you run the sqlbackup extended stored procedure, SQL Backup will first check the backup/restore rights of the user account requesting the task; it uses the SETUSER function to impersonate the logged on user account. For scheduled tasks this is the owner of the job or the SQL Agent account, for ad-hoc backup or restore tasks using the Backup or Restore wizards in the GUI, this is the account running the GUI.

In SQL 2008 and higher, the SETUSER function may be disabled or the account authentication will fail due to an issue known as 'double hop authentication' and has to do with how user security is set up on your Windows domain.

To work around this, you can disable the security check that SQL Backup performs by creating the SkipChecks registry key. To create the SkipChecks key, using Regedit navigate to the following Registry Folder: 

HKEY_LOCAL MACHINE\Software\Red Gate\SQL Backup\BackupSettingsGlobal(LOCAL) or <SQL Instance Name>

Create a new DWORD type registry key called SkipChecks and give this new key a data value of 1.
Stop and restart the SQL Backup Agent service.

Once the registry key has been created, SQL Backup will skip the user right checks for backup and restore tasks.