Original: SQL Server system database backup best Practices
First understand the main system databases:
System Database
Master |
Contains core information for login information and other databases |
msdb |
Store jobs, operators, alerts, backup restore history. Database Mail information, and so on. |
Model |
For all new database models, if you want the new database to have some objects, you can create them here. |
Tempdb |
Rebuild when SQL Server restarts, so no backup required |
In addition to the above four kinds, there is actually a database:Resource
Introduced from 2005, a read-only, hidden database that contains all of the system objects in SQL Server. The resource database is restored because SQL Server does not support backup. So the DBA needs to replicate resource's mssqlsystemresource.mdf and mssqlsystemresource.ldf files.
The resource database in SQL Server 2005 is in the path: "<drive>:\program Files\Microsoft SQL Server\mssql.1\mssql\data\" location
The resource database in SQL Server 2008 is in the path: "<drive>:\program Files\Microsoft SQL Server\mssql10.<instance_name>\ Mssql\binn\ "location.
Reporting Services Database: If you have report services installed, you will see both service databases
ReportServer
ReportServerTempDB
Replication System Database (Replication Service systems databases)
Distribution-When the replication service is configured, you will see this database.
If you need to perform a file-based backup function to back up the resource database, you need to turn on xp_cmdshell
Use Mastergosp_configure ' Show advanced options ' go/* 0 = Disabled, 1 = Enabled */sp_configure ' xp_cmdshell ', 1GORECONFIGU RE with Overridego
Use the following statement to back up the system database to the E-drivesystemdatabasebackups In the folder:
Use Mastergoselect GETDATE () as ' System database backup Start time ' go/* backup distribution database */BACKUP DATABASE Di Stribution to DISK = ' E:\SystemDatabaseBackups\Distribution.BAK ' with initgo/* backup reportserver Database */Backup DATA BASE ReportServer to DISK = ' E:\SystemDatabaseBackups\ReportServer.BAK ' with initgo/* Backup reportservertempdb Database */Backup DATABASE reportservertempdb to DISK = ' E:\SystemDatabaseBackups\ReportServerTempDB.BAK ' with initgo/* BACKUP Ma Ster model */backup DATABASE model to DISK = ' E:\SystemDatabaseBackups\Model.BAK ' with initgo/* BACKUP Master DATABASE */ Backup DATABASE Master to DISK = ' E:\SystemDatabaseBackups\Master.BAK ' with initgo/* backup Master MSDB */backup Databas E MSDB to DISK = ' E:\SystemDatabaseBackups\MSDB. BAK ' with initgo/* Copy Resource Database Files Using xp_cmdshell */EXEC xp_cmdshell ' copy/y ' D:\Program Files\Microsoft SQL Server\mssql10. Sql2008\mssql\binn\mssqlsystemresource.mdf "" E:\SystemDatabaseBackups "' Goexec xP_cmdshell ' copy/y ' D:\Program Files\Microsoft SQL Server\mssql10. Sql2008\mssql\binn\mssqlsystemresource.ldf "" E:\SystemDatabaseBackups "' goselect GETDATE () as ' System Database Backup End Time ' GO
SQL Server system database backup best Practices