Ola Halegren
install
exec het maintenance solution script
in master ( of herdoe in een dba lib db
zorg dat sql agent runt of de jobs worden niet aangemaakt
maar je kan ook later sql agent starten en het script opnieuw runnen
dat is ook de wijze voor een upgrade van de versie
script creates one table (dbo.CommandLog), one function, and four stored procedures in the master database. It also creates 11 pre-created SQL Server Agent jobs.
![[Pasted image 20221101210636.png]]
dbo.CommandExecute = core of the solution
![[Pasted image 20221101210725.png]]
customize
zie https://www.sqlshack.com/ola-hallengrens-sql-server-maintenance-solution-installation-sql-server-backup-solution/
op z’n minst :
- directory locations
- schedules van de job
see the variables in code near the top of the script (around line 32)
SET @CreateJobs = 'Y'
SET @BackupDirectory = N'C:\Backup'
SET @CleanupTime = NULL
SET @OutputFileDirectory = NULL
SET @LogToTable = 'Y'
These are also in the job step
@BackupDirectory :
The path will be used as a root directory for storing backup files.
A network share can also be used, but both SQL Server and SQL Server Agent services need to be run under a domain account with full control of the directory and the network share
@CleanupTime : integer
specifies how long (in hours) will each backup file be kept on the drive.
After the specified time passes, the file will be deleted automatically.
If default NULL value is left in the script, the backup files will never be deleted automatically
vb : 14 d = 14 * 24 = 336
@OutputFileDirectory
specifies the path for the log files that will be created after each job is run.
or leave the NULL value to use the default SQL Server error log directory
@LogToTable
only values for Yes and No.
Default value is set to Yes, and leaving this value as is will log the results of each created job in the CommandLog table