olahallengren / sql-server-maintenance-solution

SQL Server Maintenance Solution
https://ola.hallengren.com
MIT License
2.91k stars 756 forks source link

Backup Retention Feature #697

Closed mblackbird closed 1 year ago

mblackbird commented 1 year ago

I would love to see some enhancements for deleting old backups. In particular, rather than having to specify a cleanup time, to be able to say how many full backups (and all diff/logs since) that you wish to keep. So, for example, you'd say keep the 2 latest backups (including the one about to be taken) and the routine would work out the cleanup time to use for xp_delete from that parameter.

The same parameter could apply for differential and transaction log backups. You specify retention as a number of full backups with all diff/log backups kept from the point of the oldest applicable backup.

The reason I'd like to see this is that I use some data driven logic to decide which databases to backup on which days of the week. The backups are then taken by your routine. I can adjust my data on the fly to change things as I would like. But then have to calculate specific cleanup times to specify based on the new settings. Just being able to say I only want to ever retain the two most recent full backups and any diff/logs from that point onwards would be cool.

Mark

wqweto commented 1 year ago

But then have to calculate specific cleanup times to specify based on the new settings

Btw, someone has to calculate these times in the end -- either you the caller of the stored procedure or the stored procedure itself so the T-SQL logic is pretty much the same.

Your proposal seems reasonable to me so now you can try sending a PR with all this implemented and it might get included in the main branch.

This is how OSS works, it's not an à la carte restaurant where you order things from the menu in issues tab :-))

mblackbird commented 1 year ago

I understand. Just followed the link from https://ola.hallengren.com/contact.html to suggest new features is all. Also just looking at the history I've now found https://github.com/olahallengren/sql-server-maintenance-solution/issues/484 suggesting the same thing and doesn't look like Ola found a way to easily implement. So I'll close this.