SQL Server Maintenance Guide
Overview
There are two main aspects to SQL Server Maintenance:
- A disaster recovery plan.
- General maintenance of the database.
Disaster Recover Plan
Typically the disaster recover plan for a StudyTRAX database consists of the following elements:
- Periodic database backups (see Maintenance Plan Creation below).
- Storage of backups at a secure off-site location.
- Test restoring the database from a backup.
General Maintenance of the Database.
General maintenance includes activities such as Rebuilding Indexes and Updating Statistics. These activities can be scheduled through a SQL Server maintenance plan (see Maintenance Plan Creation below).
Database backup strategies
Since a StudyTRAX database is typically not very large by SQL Server standards, the following two strategies are viable options:
- Nightly Full Backups: This is also the simplest option. A full backup of the database is scheduled to be run every night. This allows a database to be restored to its state at the time of the backup. With this option, it is important to set the Recover Model for the database to Simple or else the transaction logs will grow indefinitely.
- Weekly Full Backups and Daily Transaction Log Backups: Typically a full backup is scheduled to run on each weekend and transaction log backups are scheduled to run daily. This allows a database to be restored to its state at the time of the last transaction log backup or to any prior specific time. This option also requires less storage space for backups since a transaction log backup is significantly smaller than a full database backup.
Maintenance Plan Creation
Nightly Full Backups:
- Open SQL Server Management Studio.
- Set the database Recovery Model to Simple.
- Right-click on the StudyTRAX database and select Properties from the menu.
- Right-click on the StudyTRAX database and select Properties from the menu.
- Start the Maintenance Plan Wizard.
- Right-click on Management -> Maintenance Plans and select Maintenance Plan Wizard from the menu.
- In the Select Plan Properties Window:
- Supply a name.
- Select "Single Schedule for the entire plan or no schedule."
- Click on the Change button to select a schedule for the plan to run.
- On the Select Maintenance Tasks window, select the options as in the following image:
- Click Next through the Select Maintenance Task Order page.
- Select the StudyTRAX database on the Define Database Check Integrity Task page.
- Select the StudyTRAX database on the Define Rebuild Index Task page. The other options can be left at their defaults.
- Select the StudyTRAX database on the Define Update Statistics Task page. The other options can be left at their defaults.
- Click Next through the Define History Cleanup Task page.
- Select the StudyTRAX database on the Define Back Up Database (Full) Task page. Specify where the database backup files will be created. The remaining options can be left at their defaults.
- Set options as desired on the Select Report Options page.
- Click Finish on the Complete the Wizard page.
Weekly Full Backups and Daily Transaction Log Backups:
Note, this option requires the creation of two maintenance plans: One for the weekly database backup and general maintenance and another for the nightly backups.
Weekly Database Backup and Maintenance Tasks
- Manually create the initial database backup.
- Open SQL Server Management Studio.
- Right-click on the StudyTRAX database and select Task -> Backup from the context menu.
- Ensure the Recovery Model is set to Full (the default).
- Ensure the Backup type is Full (the default).
- Select the location for the backup file.
- Start the Maintenance Plan Wizard.
- Right-click on Management -> Maintenance Plans and select Maintenance Plan Wizard from the context menu
- In the Select Plan Properties Window:
- Supply a name.
- Select "Single Schedule for the entire plan or no schedule."
- Click on the Change button to select a schedule for the plan to run.
- On the Select Maintenance Tasks window, select the options as in the following image:
- Click Next on the Select Maintenance Task Order page.
- Select the StudyTRAX database on the Define Database Check Integrity Task page.
- Select the StudyTRAX database on the Define Rebuild Index Task page. The other options can be left at their defaults.
- Select the StudyTRAX database on the Define Update Statistics Task page. The other options can be left at their defaults.
- Click Next through the Define History Cleanup Task page.
- Select the StudyTRAX database on the Define Back Up Database (Full) Task page. Specify where the database backup files will be created. The remaining options can be left at their defaults.
- Set options as desired on the Select Report Options page.
- Click Finish on the Complete the Wizard page.
Daily Transaction Log Backup
- Start the Maintenance Plan Wizard.
- Right-click on Management -> Maintenance Plans and select Maintenance Plan Wizard from the context menu
- In the Select Plan Properties Window:
- Supply a name.
- Select "Single Schedule for the entire plan or no schedule."
- Click on the Change button to select a schedule for the plan to run. It should be run every day except when the full database backups are run. One option to accomplish this schedule is in the image below.
- On the Select Maintenance Task page, select Back Up Database (Transaction Log)
- Click Next on the Select Maintenance Task Order page.
- Set options as desired on the Select Report Options page.
- Click Finish on the Complete the Wizard page