We help IT Professionals succeed at work.

How To Change Backup Paths In Backup jobs in SQL Server?

Greetings,

Wanted to know if there was a script you have that will change current backup path in SQL Server backup jobs to a new path without manually changing each backup job? We have over 50 backup jobs on 50 servers and wanted to see if there was some sort of undocumented method to do this without manually doing it. For example current backup path could be \\bakserver1\fullbkups\empdb1 and we want to change it to \\bak1\fullbackups\empdb1. Please advise.
Comment
Watch Question

Chief Technology Officer
Most Valuable Expert 2011
Commented:
Hi.

Tread lightly of course, but you can find the path in the command column of the msdb.dbo.sysjobsteps table. http://msdn.microsoft.com/en-us/library/ms187387.aspx

e.g., you can find commands with a given path and replace with another.
SELECT [command]
    , REPLACE([command], 'D:\Path1\', 'E:\Path2\')
FROM [msdb].[dbo].[sysjobsteps]
WHERE [command] LIKE '%D:\Path1\%'
;

Open in new window


Regards,
Kevin
David ToddSenior Database Administrator

Commented:
Hi,

The default backup path is stored in the registry so do take care!

The key for the default 2005 instance is:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL.1\MSSQLServer\BackupDirectory

My recommendation is to change the backup jobs, or alternatively use a database to keep your backup procedures and so on, and store a default backup path in that database. I would be reluctant to change the registry on an otherwise working production machine.

HTH
  David