I was having problems with too many backups being deleted. I started by checking out the "keep-oldest" patch (www.drupal.org//node/2350237) which seemed to help, but then realised the real problem was that I do two daily backups - the database, and the files (I don't need a daily full-site backup because I keep the code mirrored on two machines that I use for maintenance).

BM-Prune did not take this into account - when it says it keeps "one backup" that's what it means, so it would only preserve either the database or the files backup at random!

I've therefore added the logic necessary to treat the backups from each source separately. In addition, I found some flaws in the pruning logic, and I didn't like the still somewhat random selection of which files to delete, so my patch has turned into a fairly significant rework. I've changed it to be completely deterministic as to what it keeps and what it deletes. Essentially, in any slot it will aim to keep the preferred hour/day/week/month, but if not present will look for the nearest older, or if none the nearest younger. It will never delete the last remaining file in a slot regardless of its time or date.

I've also for completeness enabled configuration options for daily backups in line with the other slots, so you can choose your preferred hour, or even disable daily pruning altogether. You can also set the number of days delay before daily pruning kicks in. Weekly pruning takes over after a further 7 days, monthly after a further 28 days, and yearly after a further 365 days.

For weekly pruning, in addition to selecting a preferred day of the week, there is a "1-8-15-22" option. This preserves the oldest backup in each week in a month, counting from 1st of the month, so if backups are made daily the ones preserved will be on those days in the month.

Although there are a few more configuration settings, it is backward compatible as it will default the new settings if missing.

I've had this running for several week on two sites, backing up from multiple sources to Nodesquirrel, as well as locally for testing. Hope it works for you - enjoy!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Rick J created an issue. See original summary.

RickJ’s picture

RickJ’s picture

Assigned: Unassigned » RickJ
RickJ’s picture

For those interested ...

I've added another feature to this patch - the ability to limit the total number of backups kept. If a limit is set, and after normal pruning there are more backups than the limit, the oldest backups will be deleted as required. I needed this with NodeSquirrel in order to avoid exceeding the allocated space.

Updated patch attached.

e0ipso’s picture

Thanks for the collaboration. I am struggling to maintain this module (as you can see).

However I noticed that there are problems with the Drupal Coding Standards in that patch. If someone can test this patch and confirm it works as expected, can you please correct those coding standard violations before merging?

Again, many thanks!

RickJ’s picture

I've had a look at the coding in the patch, and I think the main issue is use of tabs rather than spaces (that said there are a lot of tabs in the original code!). Also maybe some untidy commenting.

I've corrected all that, and also tweaked the patch to work with 7.x-2.1 (#4 barfed on the patch command).