Unable to get Backup to execute as correct user
gswartwood
Posts: 5
WHen I installed the trial of backup 6 on our SQL Server, I mistakenly did not change the services execute as <domain>/SQL-SA. Since we don't have an account by that domain, scheduled backups don't work.
I searched the forums and saw that there was an extended procedure we could "install" and execute to change the login used to run scheduled backups. I used the XP to change the login to a SQL Server account that has the permissions to do backups. That didn't work, the next night's backup still ran as <domain>\SQL-SA.
I un-installed the server side component and the software from my sql server and reinstalled it. THis time I chose to have the backup software service run as local system. I also told it to connect to the software to connect to our sql server as the SQL Server account.
I schedule a new scheduled backup task and this morning, I see that it failed to run and it still tried to run it as <domain>\SQL-SA. I don't know where that came from. How can I change that?
I searched the forums and saw that there was an extended procedure we could "install" and execute to change the login used to run scheduled backups. I used the XP to change the login to a SQL Server account that has the permissions to do backups. That didn't work, the next night's backup still ran as <domain>\SQL-SA.
I un-installed the server side component and the software from my sql server and reinstalled it. THis time I chose to have the backup software service run as local system. I also told it to connect to the software to connect to our sql server as the SQL Server account.
I schedule a new scheduled backup task and this morning, I see that it failed to run and it still tried to run it as <domain>\SQL-SA. I don't know where that came from. How can I change that?
Comments
Who is the owner of the backup job as defined in SQL Server Agent?
Thanks.
SQL Backup Consultant Developer
Associate, Yohz Software
Beyond compression - SQL Backup goodies under the hood, updated for version 8
As for the owner of the backup job defined in SQL Server Agent, it is set to the SQL Server account that has permissions to perform backups and not set to <domain>\sql-sa.
SQL Backup Consultant Developer
Associate, Yohz Software
Beyond compression - SQL Backup goodies under the hood, updated for version 8
I tried using sqbsetlogin again to set the user/password. It doesn't fail, but doesn't give anything for a result either. I then set up another backup job and the new job didn't work even after setting sqbsetlogin. It kept trying to execute the backup as <domain>\sql-sa.
The end result: I can a Red Gate created scheduled job to work if I set the Run As User advanced option within the job. Otherwise, Red Gate keeps using sql-sa.
When you schedule a job using SQL Server Agent, things are slightly different. The account which the SQL Server Agent uses to log on to SQL Server depends on a few things, which are explained here. The same checks are then performed by SQL Server and SQL Backup as explained above.
In both cases, the SQL Backup Agent will always use its service startup account to log on to SQL Server to perform the backup. However, if you want the SQL Backup Agent to use a SQL Server account (SQL authentication) to log on to SQL Server, you need to use the sqbsetlogin extended stored procedure.
E.g. if instead of the Windows account used to start the SQL Backup Agent service (YOHZ\DBAAdmin), you want to use the SQL account sa, you would need to run the following:
To revert back to using Windows authentication, run the same extended stored procedure with empty parameters e.g.
SQL Backup Consultant Developer
Associate, Yohz Software
Beyond compression - SQL Backup goodies under the hood, updated for version 8
E.g.
- SQL Backup Agent service starts as RedDomain\ObiWan
- SQL Backup Agent set up to use SQL login 'sa' to run backups
- user logs on to SQL Server as RedDomain\LukeS
- user runs a backup using the command
EXEC master..sqlbackup '-sql "BACKUP DATABASE model TO DISK = [<AUTO>]"'
What happens next:
- SQL Server checks that RedDomain\LukeS has rights to run the sqlbackup extended stored procedure
- SQL Backup checks that RedDomain\LukeS has rights to back up the model database
- SQL Backup connects to the SQL Server instance as 'sa' to run the backup
To confirm that this is working as described above, start a Profiler trace and run a SQL Backup backup from SSMS. You should see that the initial backup command (master..sqlbackup) should be ran in the context of the logged on user. The actual backup command (BACKUP DATABASE ... TO VIRTUAL DEVICE = ...) will be ran in the context of your SQL Server user.
SQL Backup Consultant Developer
Associate, Yohz Software
Beyond compression - SQL Backup goodies under the hood, updated for version 8