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


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.
Who is Participating?
Kevin CrossConnect With a Mentor Chief Technology OfficerCommented:

Tread lightly of course, but you can find the path in the command column of the msdb.dbo.sysjobsteps table.

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

David ToddSenior DBACommented:

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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.