I've noticed some unexpected behavior using the database backup job in Ola's Maintenance Solution. On the test instance I'm working on, I have the user database backup job scheduled to run at 2:00am every morning. I have the @CleanupTime parameter set to 48 and I haven't specified the @CleanupMode parameter.
If I'm understanding this correctly, that should run daily and keep two copies of the the database backup... Since the default is "AFTER_BACKUP", it should delete the oldest file after the new backup completes, only leaving the oldest file if the newest backup fails. So it should start with two days' of files in the folder, create a third file (for the current day) and then delete the oldest file of the three.
What's odd is that sometimes it leaves two days' worth of files and sometimes it leaves three, even though all of the backups are successfully completing. It's not a huge issue but, in the interest of saving space on that drive, I'd prefer to only keep two backups at any given time. Any tips or suggestions would be appreciated.
Edit: As requested in the comments below, here is the list of parameters in that job step...
EXECUTE [dbo].[DatabaseBackup] @Databases = 'ALL_DATABASES', @Directory = NULL, @BackupType = 'FULL', @Verify = 'N', @CleanupTime = 48, @CheckSum = 'Y', @LogToTable = 'Y'