2

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.

2
  • 1
    I’m voting to close this question because it is off-topic. There is currently no switch to save certain *.bak files longer than other *.bak files based on some criteria other than a default cleanup time. Try and open a pull request on the repository's Github page: olahallengren / sql-server-maintenance-solution
    – John K. N.
    Dec 16, 2020 at 19:36
  • with GLOBIGNORE maybe.
    – danblack
    Dec 17, 2020 at 6:12

2 Answers 2

1

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.

0
1

From Comments:

Set up a separate job (or an intermediate step) that copies the backups you want to a different location. Then Ola's cleanup won't have any idea about the copies. - Aaron Bertrand

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.