Maintenance Plan Recommendations Guide
Database Maintenance Plans are a key piece to an effective Disaster Recovery Plan. Microsoft SQL Server Management Studio allows operators to set up email notifications on success and failure actions of steps in a maintenance plan. This is an efficient way of finding out when issues are occurring without having to log in to the server and monitor the plans. In total, New World ERP should at least have an Optimization Plan, a plan that includes a backup of the database (could be part of the Optimization Plan) and a plan that backs up the New World ERP transaction log files.
Step-by-Step
Setting Up Operators for Database Mail
- First we need to create an operator in SQL.
- Open up Microsoft SQL Server Management Studio on the database server.
- Expand the SQL Server Agent.
- Right click on Operators.
-
Click New Operator.
-
Assign an email address and name to the Operator. Click OK.
Viewing the Optimization Plan
- Maintenance Plans are set up in a Graphical User Interface (GUI) in Microsoft SQL Server Management Studio. Typically one or more will already be set up.
- Open Microsoft SQL Server Management Studio on the database server.
- Expand Management, then expand Maintenance Plans.
- Look for a plan called something like Nightly Maintenance, New World ERP Optimization or Nightly Optimization. This example is called Conference Optimization.
-
Double clicking on the plan brings it up in the right hand side of the GUI.
- The key components to any New World ERP Optimization Plan are the Check Database Integrity Task, a Rebuild Index Task, and Update Statistics.
- A Back Up Database Task is optionally included in the Optimization Plan, but it needs to occur nightly. This step is often in its own plan.
- The Maintenance Cleanup Task removes old database backup files that are older than the configured age on the step in the plan. In this case, backups older than 4 days would be removed by the plan on a successful run.
Configuring the Optimization Plan (non-existing)
- Open Microsoft SQL Server Management Studio on the database server.
- Expand Management and right click on Maintenance Plans.
-
Click New Maintenance Plans.
- Drag the components into the plan one by one from the left hand pane. Order the tasks like the image above in step 5 of Viewing the Optimization Plan.
- Check Database Integrity Task
- Rebuild Index Task
- Update Statistics Task
- Back Up Database Task
- Notify Operator Task (3)
- Maintenance Cleanup Task
-
Continue when you see something like the image below:
-
When the above picture looks similar to what is on your environment, right click on Check Database Integrity Task and click Edit.
- Choose your live and/or test database and continue.
- Right click on Rebuild Index Task in the Maintenance Plan Graphical User Interface and click Edit.
- Choose your database as in Step 7 and continue.
- Right click on Update Statistics Task in the Maintenance Plan Graphical User Interface and click Edit.
- Choose your database as in Step 7 and make sure to choose Column statistics only on the initial Edit screen.
- After setting the Update Statistics Task, right click on Back Up Database Task and click Edit.
-
Ensure the Backup type is Full. Choose your database and then provide a path to back up the database to the server or NAS. Keep in mind that several days of backups will be going to this directory for as many databases as are chosen in this step.
- Right click on Maintenance Cleanup Task and click Edit.
-
Configure the task to delete files from the same directory from above (with a life of 3 to 7 days). Ensure the sub folders are being scanned for stale files.
- After clicking OK on the Maintenance Cleanup Task, it is time to draw the arrows to link the plan together.
- Draw an arrow from Check Database Integrity Task to Rebuild Index Task. You can activate the arrow by clicking on the Check Database Integrity box.
-
The arrow should be green for Success.
-
Draw another green arrow from Rebuild Index Task to Update Statistics Task.
- The next green arrow would go from Update Statistics Task to Back Up Database Task.
- Draw another arrow from Back Up Database Task to Maintenance Cleanup Task.
-
At this point the plan should resemble the following image:
- It is time to link in Database Main for notification of Operators on failure and success.
- Draw an arrow from Check Database Integrity Task to the first Notify Operator Task.
-
Right click on this arrow and choose Failure. If Check Database Integrity fails, there is a chance of data corruption in the database. The arrow will change to a red color after choosing failure.
- Right click on the Notify Operator Task that an arrow was just connected to. Choose Edit.
-
Choose an operator to send the email to. Enter a subject and note to the Operator on what to look for.
- Draw a similar Failure arrow from Back Up Database Task to the second Notify Operator Task. Perform the same setup from Step 27 to configure the email. This notification is helpful in the event of the database server running out of hard drive space.
- Draw another arrow from the Maintenance Cleanup Task ot the final Notify Operator Task. This one should be a success arrow. Configure the email as in Step 27, this time notifying the operator that everything has finished successfully and the database is running optimally.
-
In the end, the plan should look similar to the image below.
- Finally, a schedule needs to be applied to the plan to ensure it runs daily.
-
At the top of the Maintenance Plan GUI, you will see a scheduling area. Click on the Calendar icon on the right side of the screen.
-
Configure the process to run nightly at a time when other processes are not running on the server. Maintenance Plans can severely hinder performance while the plan is running.
-
The final product should look like the image below, with all steps configured and a schedule running on the server.
Configuring/Viewing a Transaction Log Maintenance Plan
- Transaction Logs allow for hourly rollback points during the middle of the day in case of database corruption.
- A Transaction Log backup should occur every hour during the working day in the Maintenance Plan as part of the Disaster Recovery Plan.
- The Transaction Log Backup plan is much simpler to complete than the Optimization Plan. This example is the Conference TRN Log plan.
-
The same principles applied above would be used, with the difference of the schedule being run hourly during the workday and the Backup being done on a Transaction Log backup type as well as a trn File Extension.
-
The Maintenance Cleanup Plan should clean up .trn extensions instead of .bak extensions like above.
-
The final plan should resemble the following: