Skip to content

Commit 378a598

Browse files
authored
Merge pull request #1109 from BrentOzarULTD/issue_1005_3/brent
#1005 sp_AllNightLog - make ChangeBackupType db-driven
2 parents ee28485 + da2f8cd commit 378a598

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

sp_AllNightLog.sql

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ ALTER PROCEDURE dbo.sp_AllNightLog
2020
@Restore BIT = 0,
2121
@Debug BIT = 0,
2222
@Help BIT = 0,
23-
@ChangeBackupType NVARCHAR(MAX)= 'Y',
2423
@VersionDate DATETIME = NULL OUTPUT
2524
WITH RECOMPILE
2625
AS
@@ -115,6 +114,7 @@ DECLARE @msg NVARCHAR(4000) = N''; --Used for RAISERROR
115114
DECLARE @rpo INT; --Used to hold the RPO value in our configuration table
116115
DECLARE @rto INT; --Used to hold the RPO value in our configuration table
117116
DECLARE @backup_path NVARCHAR(MAX); --Used to hold the backup path in our configuration table
117+
DECLARE @changebackuptype NVARCHAR(MAX); --Config table: Y = escalate to full backup, MSDB = escalate if MSDB history doesn't show a recent full.
118118
DECLARE @encrypt NVARCHAR(MAX); --Config table: Y = encrypt the backup. N (default) = do not encrypt.
119119
DECLARE @encryptionalgorithm NVARCHAR(MAX); --Config table: native 2014 choices include TRIPLE_DES_3KEY, AES_128, AES_192, AES_256
120120
DECLARE @servercertificate NVARCHAR(MAX); --Config table: server certificate that is used to encrypt the backup
@@ -705,6 +705,11 @@ LogShamer:
705705
RETURN;
706706
END;
707707

708+
SELECT @changebackuptype = configuration_setting
709+
FROM msdbCentral.dbo.backup_configuration c
710+
WHERE configuration_name = N'change backup type'
711+
AND database_name = N'all';
712+
708713
SELECT @encrypt = configuration_setting
709714
FROM msdbCentral.dbo.backup_configuration c
710715
WHERE configuration_name = N'encrypt'
@@ -883,7 +888,7 @@ LogShamer:
883888
@BackupType = 'LOG', --Going for the LOGs
884889
@Directory = @backup_path, --The path we need to back up to
885890
@Verify = 'N', --We don't want to verify these, it eats into job time
886-
@ChangeBackupType = @ChangeBackupType, --If we need to switch to a FULL because one hasn't been taken
891+
@ChangeBackupType = @changebackuptype, --If we need to switch to a FULL because one hasn't been taken
887892
@CheckSum = 'Y', --These are a good idea
888893
@Compress = 'Y', --This is usually a good idea
889894
@LogToTable = 'Y', --We should do this for posterity
@@ -896,7 +901,7 @@ LogShamer:
896901
@BackupType = 'LOG', --Going for the LOGs
897902
@Directory = @backup_path, --The path we need to back up to
898903
@Verify = 'N', --We don't want to verify these, it eats into job time
899-
@ChangeBackupType = @ChangeBackupType, --If we need to switch to a FULL because one hasn't been taken
904+
@ChangeBackupType = @changebackuptype, --If we need to switch to a FULL because one hasn't been taken
900905
@CheckSum = 'Y', --These are a good idea
901906
@Compress = 'Y', --This is usually a good idea
902907
@LogToTable = 'Y'; --We should do this for posterity

sp_AllNightLog_Setup.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,9 @@ BEGIN
454454
INSERT dbo.backup_configuration (database_name, configuration_name, configuration_description, configuration_setting)
455455
VALUES (''all'', ''log backup path'', ''The path to which Log Backups should go.'', ''' + @BackupPath + ''');
456456
457+
INSERT dbo.backup_configuration (database_name, configuration_name, configuration_description, configuration_setting)
458+
VALUES (''all'', ''change backup type'', ''For Ola Hallengren DatabaseBackup @ChangeBackupType param: Y = escalate to fulls, MSDB = escalate by checking msdb backup history.'', ''MSDB'');
459+
457460
INSERT dbo.backup_configuration (database_name, configuration_name, configuration_description, configuration_setting)
458461
VALUES (''all'', ''encrypt'', ''For Ola Hallengren DatabaseBackup: Y = encrypt the backup. N (default) = do not encrypt.'', NULL);
459462

0 commit comments

Comments
 (0)