0% found this document useful (0 votes)
4 views

Maintenance Solution

The document outlines the steps to set up the Ola Hallengren Maintenance Solution, including downloading the necessary scripts, executing them in SQL Server Management Studio (SSMS), and scheduling backup jobs. Users need to configure parameters such as backup directory and cleanup time before executing the script, which creates stored procedures and scheduled jobs for database maintenance. Additionally, it advises on preparing backup folders and disabling any old backup solutions if transitioning to this new setup.

Uploaded by

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

Maintenance Solution

The document outlines the steps to set up the Ola Hallengren Maintenance Solution, including downloading the necessary scripts, executing them in SQL Server Management Studio (SSMS), and scheduling backup jobs. Users need to configure parameters such as backup directory and cleanup time before executing the script, which creates stored procedures and scheduled jobs for database maintenance. Additionally, it advises on preparing backup folders and disabling any old backup solutions if transitioning to this new setup.

Uploaded by

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

Document: Setting up Ola Hallengren Maintenance Solution

Step 1: Download Ola Hallengren Scripts

• GOTO sharepoint to download Database Administration

• Download : MaintenanceSolution.sql

Step 2: Execute MaintenanceSolution.sql in SSMS

1. Open SSMS

2. Connect to your server

For Express Edition, you won’t get SQL Agent jobs. Use Task Scheduler instead (I'll
show below).

3. Create DBAMgmt Database

4. Open MaintenanceSolution.sql

5. Modify these parameters if needed:


DECLARE @CreateJobs nvarchar(max) = 'Y' -- Specify whether jobs
should be created.
DECLARE @BackupDirectory nvarchar(max) = 'D:\SQLDBBackups' -- Specify
the backup root directory. If no directory is specified, the default backup
directory is used.
DECLARE @CleanupTime int = 120 -- Time in hours, after
which backup files are deleted. If no time is specified, then no backup files are
deleted.
DECLARE @OutputFileDirectory nvarchar(max) = NULL -- Specify the output
file directory. If no directory is specified, then the SQL Server error log
directory is used.
DECLARE @LogToTable nvarchar(max) = 'Y' Execute the script

This creates:

• Stored procedures in master

• CommandLog table created in DBAMgmt Database (if enabled)

• SQL Agent jobs (if SQL Agent exists). Rename the job name by adding
‘DBAMgmt –‘ in front of jobs created by the MaintenanceSolution.sql. Jobs are
listed below for reference.

Step 4: Scheduling

Below is the list of jobs:

• DatabaseBackup Jobs

DBAMgmt - DatabaseBackup - SYSTEM_DATABASES – FULL


- Occurs every day at 12:00pm
DBAMgmt - DatabaseBackup - USER_DATABASES – FULL
- Occurs every day at 12:10pm
DBAMgmt - DatabaseBackup - USER_DATABASES – LOG
-Occurs every 15mins
Below jobs are scheduled every day from 1:00 PM with the 00:10 minute time
interval

• IndexOptimize Job

DBAMgmt - IndexOptimize - USER_DATABASES

• DatabaseIntegrityCheck Jobs

DBAMgmt - DatabaseIntegrityCheck - SYSTEM_DATABASES

DBAMgmt - DatabaseIntegrityCheck - USER_DATABASES

DBAMgmt - DatabaseIntegrityCheck - USER_DATABASES

• Cleanup Jobs

DBAMgmt - Output File Cleanup


DBAMgmt - sp_delete_backuphistory
DBAMgmt - sp_purge_jobhistory
DBAMgmt - CommandLog Cleanup
Step 3: Backup Folder Preparation

Make sure these folders exist:

• D:\SQLBackups

Give the SQL Server service account Read/Write access.

Step 5: Disable old backup solution

After a new backup setup solution. Need to disable the old backup solution.

If you're using SQL Express (no Agent):

Use Task Scheduler to run with sqlcmd:

1. Create a .bat file:

bat

CopyEdit

sqlcmd -S .\SQLEXPRESS -E -Q "EXECUTE dbo.DatabaseBackup @Databases =


'ALL_USER', @Directory = N'D:\SQLBackups', @BackupType = 'FULL', @Compress = 'Y'"

2. Schedule this .bat to run daily via Task Scheduler

You might also like