Restoring the master database
Published 18 February 2013
To restore the master database, you must use the SQL Backup command line to ensure that the SQL Server is started in single user mode. It is not possible to restore the master database with the Restore wizard.
- Stop the SQL Server service.
- Open a Command Prompt window, and navigate to the SQL Server instance's Binn folder.
- Start SQL Server in single user mode using
sqlservr.exe -c -m
for an unnamed instance, orsqlserver -c -m -s <instance name>
for a named instance. Use the SQL Backup command line interface (
SQLBackupC.exe
) to restore the master database.
For example, at the command prompt, type:SQLBackupC.exe -SQL "RESTORE DATABASE master FROM DISK = 'C:\Backups\master 20070101.sqb'"
For a named instance, use the -I parameter to specify the instance name, for example:
SQLBackupC.exe -SQL "RESTORE DATABASE master FROM DISK = 'C:\Backups\master 20070101.sqb'" -I Instance2
If you are using SQL Server authentication, use the -U and -P parameters to add the authentication details, for example:
SQLBackupC.exe -SQL "RESTORE DATABASE master FROM DISK='C:\Backups\master 20070101.sqb'" -I Instance2 -U sa -P MyPassword
If you are restoring the master database to a new (or rebuilt) server you will need to add the WITH REPLACE keyword, for example:
SQLBackupC.exe -SQL "RESTORE DATABASE master FROM DISK='C:\Backups\master 20070101.sqb' WITH REPLACE" -I Instance2
SQL Backup restores the master database, and SQL Server automatically stops the SQL Server service when the restore operation is complete.
- You can now start the SQL Server in normal mode.
See Using the command line for more information.