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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kevin CrossChief 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


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.