Monday, November 16, 2009

Change SQL Server default backup folder

If, like me, you have a folder other than the default where you like to keep all your database backups, you've probably wondered why there is no option in the server properties to specify this folder. It gets to be a royal pain if you are doing a lot of backups through management studio and you have to navigate back from something like C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\ to c:\backups\ each time.


Fortunately, there is a way to change this setting as it is stored in the windows registry and can be easily modified using Regedit. If you have multiple instances of SQL Server installed, you will have multiple folders under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\ but you will be looking for the key called BackupDirectory in a folder like HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL.3\MSSQLServer\

Update this key and you'll see your default backup folder change. I have three instances installed (SQL Express, SQL 2005 and SQL 2008) and I updated the keys for both 2005 and 2008.

This will affect backups you execute using the UI but will also affect backups you run from the command line, so a BACKUP statement with no folder specified will also default to the new location.

No comments:

Post a Comment