MSSQL Maintenance

Ola Hallengren Maintenance Solution

Install

Download and run the single install script. This will install default scheduled jobs (but will not schedule them). The default jobs may not be setup as shown below. Review and update as necessary....

DatabaseBackup

DatabaseBackup - SYSTEM_DATABASES - FULL

SELECT *   FROM sys.configurations WHERE name LIKE '%compression%'

EXECUTE [dbo].[DatabaseBackup]

@Databases = 'SYSTEM_DATABASES',

@Directory = NULL,

@BackupType = 'FULL',

@Verify = 'Y',

@CleanupTime = 48,

@CheckSum = 'Y',

@LogToTable = 'Y'

DatabaseBackup - USER_DATABASES - FULL

Consider the implications to your restore strategy of doing this. Also consider how this impacts any backup of these backup files to another backup tool. i.e. this works best if the other backup tool doesn't backup up the FULL and all DIFF backups every night but backs up only the files that have changed. It does mean restoring more files in order to perform any recovery though.
SELECT *   FROM sys.configurations WHERE name LIKE '%compression%'

EXECUTE [dbo].[DatabaseBackup]

@Databases = 'USER_DATABASES',

@Directory = NULL,

@BackupType = 'FULL',

@Verify = 'Y',

@CleanupTime = 27,

@CheckSum = 'Y',

@LogToTable = 'Y'

DatabaseBackup - USER_DATABASES - LOG

SELECT *   FROM sys.configurations WHERE name LIKE '%compression%'

EXECUTE [dbo].[DatabaseBackup]

@Databases = 'USER_DATABASES',

@Directory = NULL,

@BackupType = 'LOG',

@Verify = 'Y',

@CleanupTime = 50,

@CheckSum = 'Y',

@LogToTable = 'Y'

DatabaseIntegrityCheck

DatabaseIntegrityCheck - SYSTEM_DATABASES

EXECUTE [dbo].[DatabaseIntegrityCheck]

@Databases = 'SYSTEM_DATABASES',

@LogToTable = 'Y'

DatabaseIntegrityCheck - USER_DATABASES

EXECUTE [dbo].[DatabaseIntegrityCheck]

@Databases = 'USER_DATABASES',

@LogToTable = 'Y'

IndexOptimize - USER_DATABASES

EXECUTE dbo.IndexOptimize

@Databases = 'USER_DATABASES',

@FragmentationLow = NULL,

@FragmentationMedium = 'INDEX_REORGANIZE',

@FragmentationHigh = 'INDEX_REBUILD_ONLINE,INDEX_REBUILD_OFFLINE',

@FragmentationLevel1 = 50,

@FragmentationLevel2 = 80,

@LogToTable = 'Y'

UpdateStats - USER_DATABASES

EXECUTE dbo.IndexOptimize

@Databases = 'USER_DATABASES',

@FragmentationLow = NULL,

@FragmentationMedium = NULL,

@FragmentationHigh = NULL,

@UpdateStatistics = 'ALL',

@OnlyModifiedStatistics = 'Y',

@LogToTable = 'Y';

Housekeeping Jobs

CommandLog Cleanup

Output File Cleanup

sp_delete_backuphistory

sp_purge_jobhistory

syspolicy_purge_history

Bibliography