SQL Database Maintenance Solution V 2 2
SQL Database Maintenance Solution V 2 2
SQL Database Maintenance Solution V 2 2
CONTENTS
2.0 18/06/2016 Combine install, configuration and remove scripts into one
Update solution script with latest version of Ola script to
2.1 01/11/2016
include support for SQL2016
Remove backup option used for SDP, add weekly full and
twice Weekly full backup options, remove stats job
Add @UpdateStatistics = 'ALL', @OnlyModifiedStatistics
= 'Y', @FragmentationLevel1 = 10 to IndexOptimize
2.2 31/05/2017 Change system full backup schecule to daily at 5:10pm
(was 6:00am) and set CleanupTime = 24
Add @JobOwnerLoginName = SUSER_SNAME(0x01) for
cycle error log job creation to handle renamed 'sa'
account
Document acceptance
Review cycle
This document should be reviewed when there has been further changes to the solution architecture,
and the updated changes referenced in this document.
Document reviewers
Approvers
Spark Digital
Document contributors
2.1 Process
This document outlines the standard operating procedure for implementing the Ola database
maintenance solution. The following install and test scripts are used to implement the solution.
OlaMaintenanceSolution_ v2_2.sql
OlaTestAndEnableJobs_v2_0.sql
The first script is the main install script and will create the stored procedures, command log
table and SQL jobs for the Ola solution. The script will also remove any existing Ola objects on
the server as part of the install process. The configuration section of the script will add an
additional maintenance jobs for recycling the SQL server error logs.
The second script is a supporting script that can be used to initiate a test run of the
maintenance jobs. The test script will not run the Integrity Check and Index Optimize jobs for
user databases because these jobs can be resource intensive.
2.4 Pre-requisites
Remote desktop access to the target system with Administrative privileges on the host and
SQL server. Ability to copy the implementation scripts to the target system.
2.5 Preparations
Confirm database backup and maintenance requirements and verify that the Ola solution will
meet the requirements. Highlight any gaps or concerns to the project and/or customer.
Confirm appropriate backup location with adequate capacity is available. Review and disable
any backup and maintenance procedures currently on the system.
3 Process
1. Copy the scripts to the target server from the team intranet site.
http://intranet/activity/00664/dba/Scripts/OlaMaintenanceSolution_v2_2.zip
Run Mode
o 0 = Report Only Mode: Shows parameter values and list existing maintenance
jobs already on the server.
o 1 = Install Mode: Creates the Ola stored procedures, Command Log table and
SQL server jobs. The script will also remove any existing Ola solution objects
on the target instance as part of the install process.
o 2 = Remove Only Mode: Delete Ola stored procedures, Command Log table
and SQL server jobs without replacing any of the objects.
Backup Option
o 1 = Weekly Full, Daily Diff, Log Every 15 Minutes (Local Disk + Tape). This
backup option will configure full database backups to run weekly with backup
file clean-up after 12 hours. This will effectively retain one full backup file on
disk for 7 days. The differential backup will run daily with clean-up after 60
hours retaining differential backup files for 72 hours. The clean-up mode for
the full and differential backups is set to delete old backup files before the
backups run. Transaction log backups are configured to run every 15 minutes
with clean-up after 72 hours. The default clean-up mode is used for
transaction log backups to delete old backup files after backups are taken.
System databases are backed up daily with backup file clean-up after 24
hours retaining system backup files for 48 hours.
o 2 = Twice Weekly Full, Daily Diff, Log Every 15 Minutes (Local Disk + Tape).
This backup option will configure full database backups to run twice weekly on
Monday and Thursday with backup file clean-up after 12 hours. This will
effectively retain one full backup file on disk for a minimum of 3 days. The
differential backup will run daily with clean-up after 60 hours retaining
differential backup files for 72 hours. The clean-up mode for the full and
differential backups is set to delete old backup files before the backups run.
Transaction log backups are configured to run every 15 minutes with clean-up
after 72 hours. The default clean-up mode is used for transaction log backups
to delete old backup files after backups are taken. System databases are
backed up daily with backup file clean-up after 24 hours retaining system
backup files for 48 hours.
o 3 = Daily Full, Daily Diff, Log Every 15 Minutes (Local Disk + Tape). This
backup option will configure full database backups to run daily with backup file
clean-up after 12 hours. This will effectively retain one full backup file on disk
for 24 hours. A differential backup will also run daily with clean-up after 24
hours retaining differential backup files for 48 hours. Transaction log backups
are configured to run every 15 minutes with clean-up after 72 hours. The
default clean-up mode is used for all backups to delete old backup files after
backups are taken. System databases are backed up daily with backup file
clean-up after 24 hours retaining system backup files for 48 hours.
Backup Location
3. Backup option 1 is the preferred option. Backup option 2 is the next preferred options for
systems where differential backup sizes may surpass full backup sizes before the weekly
full backup runs. Backup option 3 is used if both options 1 or 2 can’t be used successfully.
4. After running the script in Report Only Mode and parameter values are confirmed as valid,
run the script with option 1 for Install Mode.
5. Check in Management Studio that the maintenance jobs has been created and
configured.
Before running the test script review the database sizes and available free space on disk
where the backup folder is located. The test script will run all the low impact maintenance jobs
one by one starting with the Full database backup jobs.
The integrity check and index optimization jobs for user databases will not be run by the test
script. These jobs may impact systems with large databases if ran during business hours. The
DBA need to evaluate the situation checking the size of the user databases and decide if it will
be safe to run the jobs at the time or leave them to run after hours on the configured
schedules. The decision need to be made based on the criticality of the target system and the
perceived impact relative to the size of the databases.
4 Schedules
5 Known Issues
5.1.1 Invalid object name '#Config' message on SQL Server 2005 instances
This message only appears on SQL Server 2005 instances when the install script is run in
Report Only Mode or Remove Only Mode. The message have no effect and can be ignored.
This seems to be a parse issue on SQL 2005 when using the SET NOEXEC ON option.