Sql-server – Custom Deletion for Ola Hallengren Scripts

ola-hallengrensql server

I am trying to find a way to delete backups being taken by Ola's native SQL backups.

I need to keep only 2 weeks of transaction logs, 5 weeks of differentials, 14 weeks of full backups, 13 monthly full backups, and 3 beginning-of-the-year full backups.

I already asked the question and can do the first three with changing the @CleanupTime parameter in each of the respective jobs, however I don't know how to stop the Ola scripts from deleting the monthly or beginning-of-the-year backups.

Best Answer

If this is your required backup retention policy, then could you not have an extra backup job that runs once a month, and another running at once a year. These two new jobs would point to their own directory and have their own retention policy.

The downside is once a year you'll do 3 at once, daily, monthly and yearly one. But this is a rare event.

I would question if all this backups are needed, would the data be stale and no good by then? Could you lose a year's worth of data if you needed to restore it. If you want it for looking back at the data, is a DWH more suited?

However I don't no the reasons why this is required, there is probably a good reason for your approach. Such as cost saving.