0% found this document useful (0 votes)
18 views8 pages

Backup System Databases Using Maintenance Plans

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views8 pages

Backup System Databases Using Maintenance Plans

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 8

Backup System Databases Using Maintenance Plans

By : Ashish Kumar Mehta

Nov 17, 2008

System databases are an integral part of SQL Server, as SQL Server is dependant on the
System Databases for functionality. Database Administrators should make sure that all the
system databases are part of their day to day backups. Most importantly, database
administrators should take full backup of all the system databases immediately after they have
applied any Hotfixes or Service Packs. Backups of system databases will let you restore and
recover the SQL Server system in the event of system failure, such as the loss of hard disk,
database corruption, hardware/operating system crashes or any natural disaster. As a DBA you
need to make sure that the system databases are backed up regularly along with all the user
databases and the backup tapes are stored in a secure location. To know more about system
databases in SQL Server you can refer to my previous article titled “System Databases in SQL
Server”.

Permissions Required to Create & Manage Maintenance Plans


Maintenance Plans are only displayed to those users who are connected to the SQL Server
using Windows Authentication Mode. Moreover, you need to be a member of sysadmin fixed
server role to create and manage maintenance plans. The maintenance plans on the SQL
Server are visible only to those users who are member of sysadmin fixed server role.

Using Maintenance Plans to Backup System Databases


In this article we will be creating a Maintenance Plan using SQL Server Integration Services
(SSIS) Designer Surface to backup all the system databases in SQL Server. To know more
about different types of maintenance plan tasks that are available in SQL Server 2005 or SQL
Server 2008 and their usage you can refer to my previous article titled “Overview of
Maintenance Plans in SQL Server 2008”.

1. Connect to SQL Server 2008 Instance using SQL Server Management Studio.

2. In the Object Explorer, click on Management and right click Maintenance Plans to open up
the popup windows as shown in the below snippet. In the popup windows you need to click on
New Maintenance Plan….

3. In the New Maintenance Plan screen you need to provide the name of the Maintenance Plan.
In this example the name for the Maintenance Plan is “BackupSystemDatabases’. Click OK to
open up the SSIS Designer Surface as shown in the below snippet.
4. In the BackupSystemDatabases designer surface, you have the option to provide the
description for the Maintenance Plan, Name & Description for Subplan, Manage Connections,
and Configure Schedules.

5. Double click on Subplan_1 text which will open up Subplan Properties windows where you
can provide the Name and Description about the Subplan as shown in the below snippet.

6. Next step will be to configure schedule for the maintenance plan which can be done by
clicking calendar icon. In the Job Schedule Properties windows provide the details as shown in
the below snippet and click OK to save the Job Schedule Properties window.
7. Next step will be to create a connection to SQL Server where the Maintenance Plan needs to
execute. This can be done by clicking on Manage Connections…. and from the popup you need
to select Add new connection…. which will indeed open up Connection Properties window. In
the Connection Properties window you need to provide Connection Name, Server Name and
choose appropriate authentication mode. To save the connection properties click OK.

8. Next step will be to drag and drop Back up Database Task, History Cleanup Task and
Maintenance Cleanup Task on the Designer Surface to configure Maintenance Plan.
9. Double click on Backup Database Task or right click and select Edit…. Option to configure
the Backup Database Task. Provide Connection details, Select Backup type as Full from the
dropdownlist, For Databases select All system databases from the dropdownlist (if you have
reporting service and replication installed and configured then you need to choose reporting
services and replication related distribution databases using the specify choose database
option), provide the database backup location. If you are interested in verifying backup
integrity then you can select the Verify backup integrity option. In SQL Server 2008, Microsoft
introduced much awaited inbuilt database backup compression feature. If you want system
databases to be backed up using backup compression feature then you can choose
“Compressed Backup” option in the dropdownlist. To know more about database backup
compression feature of SQL Server 2008 you can refer to my previous article titled “How to
configure and Use Database Backup Compression in SQL Server 2008”. Finally click OK to save
the configuration changes done to Back Up Database Task.
10. Double click on History Cleanup Task to configure the task as shown in the below snippet.
To remove historical data you need to provide the history retention time and click OK to save
the configuration changes.

11. Double click on Maintenance Cleanup Task to open up the configuration screen and provide
the database backup folder location and also provide the extension of the files which needs to
be removed at the end of retention period.
12. Finally you need to connect the green arrow from the Back up Database Task to History
Cleanup Task and in the next step you need to connect the green arrow from the History
Cleanup Task to Maintenance Cleanup Task to complete Maintenance Plan configuration.
13. You could see that Maintenance Plan is currently configured to take full backup of master,
msdb and model databases. However, in SQL Server 2005 and higher versions there is a new
hidden read only system database named Resource database which was introduced by
Microsoft. To know more about Resource Database you can refer to my previous article titled
“Importance of the Resource Database”. Resource database basically contains copies of all
system objects that are shipped with SQL Server 2005 and SQL Server 2008. In order to take
the backup of Resource Database you need to perform a file based or a disk based backup of
mssqlsystemresource.mdf and mssqlsystemresource.ldf files, by treating the files as if they
were like any other binary files, instead of a database file.

14. In Maintenance Plan as there is no other task available which performs file copy of
Resource Database (MDF & LDF Files), the only option available with us is to add a new step
manually within the SQL Server Agent Job
“BackupSystemDatabases.BackupSystemDatabases” which was created by the Maintenance
Plan. The command used for copying mssqlsystemresource.mdf and mssqlsystemresource.ldf
files is mentioned below.

Syntax
XCOPY "D:\Program Files\Microsoft SQL Server\MSSQL10.SQL2008\MSSQL\Binn\
mssqlsystemresource.*" "D:\DatabaseBackups" /Y

15. Before saving the SQL Server Agent Job you need to make sure that the jobs success and
failure criteria for each steps are modified and it resembles as shown in the above snippet.

Executing the Newly Created Maintenance Plan


Once the “Basic Maintenance Plan for AdventureWorks databases” is created successfully you
can execute the same either by right clicking the plan and then clicking Execute under the
Maintenance Plans. Or you can expand the Jobs under SQL Server Agent node and execute the
following SQL Server Agent Job BackupSystemDatabases.BackupSystemDatabases.

Conclusion
Database Administrators should make sure that all the system databases are part of the day to
day backups. If you have applied any Hotfixes or Service Packs then immediately you should
take a backup of all the system databases including the hidden read only Resource Database.
If you have proper backups of system databases then you will be able to restore and recover a
SQL Server system in the event of system failure. In this article we have seen how to leverage
Maintenance Plans to take a backup of all the system databases.

You might also like