sql-server-maintenance-solution icon indicating copy to clipboard operation
sql-server-maintenance-solution copied to clipboard

Backup cleanuptime cannot be changed when using @modificationlevel

Open wfvdijk opened this issue 3 years ago • 1 comments

I am doing DIFF backups unles the modification level is above a certain treshold. DIFF backups should only last for 24 hours, FULL backups for 2 weeks. However, I cannot specify a retentiontime for every backuptype. If I specify 24 hours and the backup is switching from DIFF to FULL, a lot of my FULL backups got deleted (the ones older than 24 hours) I currently have the @cleanuptime set to 2 weeks, but as a result I got a lot of unnecessary DIFF backups.

In order to fix this I would like to change the @retentiontime to @retentionTimeLog, @retentiontimeDiff and @retentiontimeFull

wfvdijk avatar Jul 27 '22 09:07 wfvdijk

I have been looking at this.

Currently the code looks like this:

      -- Delete old backup files, after backup
      IF ((@CurrentBackupOutput = 0 AND @Verify = 'N')
      OR (@CurrentBackupOutput = 0 AND @Verify = 'Y' AND NOT EXISTS (SELECT * FROM @CurrentBackupSet WHERE VerifyOutput <> 0 OR VerifyOutput IS NULL)))
      AND (@BackupSoftware <> 'DATA_DOMAIN_BOOST' OR @BackupSoftware IS NULL)
      AND @CurrentBackupType = @BackupType

As you see, cleanup will not be performed when the backup type is changed. This is to protect against scenarios, where you have different retentions for the different backup types.

I will consider introducing additional parameters as you suggest.

olahallengren avatar Nov 21 '24 20:11 olahallengren