Cleanup of AG databases on secondaries nodes

by MrKudz   Last Updated May 16, 2018 14:06 PM

Consider a scenario where you have an AG running across 3 nodes and your backups are being backed up locally. Each node have all the default jobs deployed and scheduled to run at same time. As the databases are part of the AG, backups are only being taken on the PRIMARY NODE. After failover to a different node, the backups stored in the previous PRIMARY are not being deleted.

I thought that this could be happening since the default for the cleanup is AFTER_BACKUP and since no backups were happening on that node, the cleanup was not happening. I tried changing this to 'AFTER_BACKUP' to no avail.

Am I missing anything obvious or is there anything I can do ?

Command running on every node

     sqlcmd -E -S $(ESCAPE_SQUOTE(SRVR)) -d DBAAdmin -Q "EXECUTE [dbo].[DatabaseBackup] @Databases = 'USER_DATABASES', @Directory = N'L:\Backups', @BackupType = 'FULL',@Compress='Y', @Verify = 'Y', @CleanupTime = 72, @CheckSum = 'Y', @LogToTable = 'Y'" -b

Thank you

Related Questions

Index Optimize cause DB size increasement

Updated February 12, 2018 09:06 AM

Custom backup deletion Ola Scripts

Updated November 30, 2018 04:06 AM

Custom Deletion for Ola Hallengren Scripts

Updated December 01, 2018 16:06 PM