Cleanup of AG databases on secondaries nodes 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 'BEFORE_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
The current design is that the stored procedure will decide if the database should be backed up. Only if the database should be backed up, it will go into the code that does the work (creates sub-directories, backup, verify, and cleanup).

It could make sense that if you are running with @CleanupMode = 'BEFORE_BACKUP', then it should delete backups, even if the database should not be backed up.

Could you create an issue for this on GitHub.

https://github.com/olahallengren/sql-server-maintenance-solution/issues