How to change default backup location in SQL Server

In this article, we will see how to change default backup location in SQL Server.

When you install a SQL Server instance you have the opportunity to identify the default location for your instance database backups. If you don’t change the default location for your installation your default backups location will be “C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQL2019\MSSQL\Backup” (default location for a SQL Server 2019 installation). Overtime you might decide you want to change the default location for database backups.

Two different ways to change default backup location in SQL Server:

1. Using SQL Server Management Studio
2. Using Script

1. Using SQL Server Management Studio(SSMS)

1. Open SSMS, then right click on SQL Server instance and select properties as shown below.

How to change default backup location in SQL Server

2. Then select database settings. Then go to database default location. There replace Backup path to new path.

3. After changing path of backup then click on ok.

No need to restart SQL Server to effect this change.

2. Using SQL Server Management Studio(SSMS)

EXEC master..xp_regwrite @rootkey='HKEY_LOCAL_MACHINE', @key='SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL15.MSSQL2019\MSSQLServer', @value_name='BackupDirectory', @type='REG_SZ', @value='E:\backups'

Now test by taking backup using below command

backup database test to disk ='test.bak';