Sunteți pe pagina 1din 11

Internal Name of document | Page 2 of 11

CONTENTS

1 DOCUMENT CONTROL ...................................................................................... 4


Version control.................................................................................................................................. 4
Document acceptance ...................................................................................................................... 4
Review cycle ..................................................................................................................................... 4
Document reviewers ......................................................................................................................... 4
Approvers ......................................................................................................................................... 4
Document contributors ..................................................................................................................... 4
2 Overview.............................................................................................................. 6
2.1 Process .............................................................................................................................. 6
2.2 Impact and risk of disruption .............................................................................................. 6
2.3 Change Governance .......................................................................................................... 6
2.4 Pre-requisites ..................................................................................................................... 6
2.5 Preparations....................................................................................................................... 7
3 Process................................................................................................................ 7
3.1 Install Maintenance Solution .............................................................................................. 7
3.2 Test and Enable Maintenance Jobs .................................................................................. 9
3.3 Remove Maintenance Solution .......................................................................................... 9
4 Schedules............................................................................................................ 9
4.1 Scheduled Times – Backup Option 1 – Weekly Full ......................................................... 9
4.2 Scheduled Times – Backup Option 2 – Twice Weekly .................................................... 10
4.3 Scheduled Times – Backup Option 3 – Daily Full ........................................................... 10
4.4 Scheduled Times – Database Maintenance Jobs ........................................................... 10
5 Known Issues ................................................................................................... 11
5.1.1 Invalid object name '#Config' message on SQL Server 2005 instances ........................ 11

Internal Title of document | Page 3 of 11


1 DOCUMENT CONTROL
Version control

Version Date Description of Changes Author

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

This document has been approved and accepted by:

Name Role/On behalf of Date Signature

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

Name Role/On behalf of Date Signature

Approvers

This document has been peer reviewed by and accepted by:

Reviewer/s Date Version Notes


Reviewed

Spark Digital

Document contributors

This document has been contributed to by the following resources:

Name Role/On behalf of

Title of document | Page 4 of 11


Document control

Title of document | Page 5 of 11


2 Overview

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.

The scripts are available on the team intranet site.

2.2 Impact and risk of disruption

Impact and risk of disruption: Low


The implementation of this solution has very low impact and risk of disruption. The
maintenance tasks implemented are scheduled to run after hours and are not expected to
impact on users during business hours.

Business benefit of implementation: High


Database backup and maintenance procedures are critical for database health, performance
and recoverability. This standard operating procedure enables quick deployment and
consistency across systems.

2.3 Change Governance

Pre-approved standard operational activity business hours

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.

Title of document | Page 6 of 11


Section title

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

3.1 Install Maintenance Solution

1. Copy the scripts to the target server from the team intranet site.
http://intranet/activity/00664/dba/Scripts/OlaMaintenanceSolution_v2_2.zip

2. Open the install scrip (OlaMaintenanceSolution_v2_2.sql) in Management Studio and


select values for the three main parameters. Run the script in Report Only Mode first to
review and validate selected parameters values.

 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.

Backup Type Frequency File Retention Files/DB

Full (User) Weekly 7 Days 1


Diff (User) Daily 3 Days 3
Log (User) 15 Minutes 3 Days 288
Full (System) Daily 2 Day 2

Title of document | Page 7 of 11


Section title

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.

Backup Type Frequency File Retention Files/DB

Full (User) Twice Weekly 3 Days 1


(Mon/Thu)
Diff (User) Daily 3 Days 3
Log (User) 15 Minutes 3 Days 288
Full (System) Daily 2 Day 2

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 Type Frequency File Retention Files/DB

Full (User) Daily 1 Day 1


Diff (User) Daily 2 Days 2
Log (User) 15 Minutes 3 Days 288
Full (System) Daily 2 Days 2

 Backup Location

o Local Disk Standard Location = U:\InstanceID.InstanceName\MSSQL\Backup

Examples of standard backup locations

o SQL 2016 - U:\MSSQL13.INSSQL01\MSSQL\Backup


o SQL 2014 - U:\MSSQL12.INSSQL01\MSSQL\Backup
o SQL 2012 - U:\MSSQL11.INSSQL01\MSSQL\Backup
o SQL 2008 R2 - U:\MSSQL10_50.INSSQL01\MSSQL\Backup
o SQL 2008 - U:\MSSQL10.INSSQL01\MSSQL\Backup

Title of document | Page 8 of 11


Section title

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.

3.2 Test and Enable Maintenance Jobs

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.

1. To run the test script, open the script (OlaTestAndEnableJobs_v2_0.sql) in Management


Studio and connect to the target instance.
2. Open SQL Agent job activity monitor to monitor the progress and run status of the jobs.
3. Review job output files in the Output Files folder.
4. Confirm an output file has been created for each tested job.

3.3 Remove Maintenance Solution

To remove the Maintenance Solution run the install script (OlaMaintenanceSolution_v2_2.sql)


with option 2 for Remove Only Mode. The script will remove all the Ola stored procedures,
Command Log table and SQL server jobs from the SQL server instance. Note the script will
not remove the backup or output files.

4 Schedules

4.1 Scheduled Times – Backup Option 1 – Weekly Full

Database Backup Task Default Task Schedule

Database Backups – System Databases – Full Daily at 5:10:00 p.m.


Database Backups – User Databases – Full Weekly on Monday at 6:10:00 p.m.
Database Backups – User Databases – Diff Daily at 7:10:00 p.m.
Database Backups – User Databases – Log Every 15 minute(s) between 12:00:00 a.m. and
11:59:59 p.m.

Title of document | Page 9 of 11


Section title

4.2 Scheduled Times – Backup Option 2 – Twice Weekly

Database Backup Task Default Task Schedule

Database Backups – System Databases – Full Daily at 5:10:00 p.m.


Database Backups – User Databases – Full Twice Weekly Monday, Thursday at 6:10:00 p.m.
Database Backups – User Databases – Diff Daily at 7:10:00 p.m.
Database Backups – User Databases – Log Every 15 minute(s) between 12:00:00 a.m. and
11:59:59 p.m.

4.3 Scheduled Times – Backup Option 3 – Daily Full

Database Backup Task Default Task Schedule

Database Backups – System Databases – Full Daily at 5:10:00 p.m.


Database Backups – User Databases – Full Daily at 6:10:00 p.m.
Database Backups – User Databases – Diff Daily at 7:10:00 p.m.
Database Backups – User Databases – Log Every 15 minute(s) between 12:00:00 a.m. and
11:59:59 p.m.

4.4 Scheduled Times – Database Maintenance Jobs

Database Maintenance Task Default Task Schedule

Database Integrity Check – System Databases Weekly on Saturday at 12:00:00 a.m.


Database Integrity Check – User Databases Weekly on Saturday at 12:30:00 a.m.
Database Index Optimize – User Databases Weekly on Sunday at 1:00:00 a.m.
Delete Backup History Weekly on Saturday at 4:20:00 a.m.
Purge Job History Weekly on Saturday at 3:30:00 a.m.
Output File clean up weekly on Saturday at 3:00:00 a.m.
Command Log clean up Weekly on Saturday at 2:00:00 a.m.
Cycle SQL Error Log Weekly on Sunday at 12:00:00 a.m.

Title of document | Page 10 of 11


Section title

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.

Title of document | Page 11 of 11