xolox/python-rotate-backups

Preserving the most recent backups

tonyo opened this issue · 2 comments

tonyo commented

Let's assume that I have two backups:

backup-2016-01-10_21-15-00.tar.gz
backup-2016-01-10_21-45-00.tar.gz

Then I do:

$ rotate-backups --hourly=1 --dry-run dir/ 
2016-08-03 12:44:41 tonyhost rotate_backups.cli[6556] INFO Performing a dry run (because of --dry-run option) ..
2016-08-03 12:44:41 tonyhost rotate_backups[6556] INFO Scanning /home/tonyo/tmp/backup_rotate/dir for backups ..
2016-08-03 12:44:41 tonyhost rotate_backups[6556] INFO Found 2 timestamped backups in /home/tonyo/tmp/backup_rotate/dir.
2016-08-03 12:44:41 tonyhost rotate_backups[6556] INFO Preserving ~/tmp/backup_rotate/dir/backup-2016-01-10_21-15-00.tar.gz (matches 'hourly' retention period) ..
2016-08-03 12:44:41 tonyhost rotate_backups[6556] INFO Deleting ~/tmp/backup_rotate/dir/backup-2016-01-10_21-45-00.tar.gz ..

So rotate-backups removes the second, more recent backup (..._21-45-...). Could you please clarify why we don't want to keep the most recent one, and remove the one made at 21:15?
Does it make sense to add some option (like --keep-recent) to change this behaviour and keep the latest backups?

As a general (and somehow related) question, is it planned to introduce a minutely option to enable rotation if backups are made several times per hour?

xolox commented

Hi Anton and thanks for the feedback.

Could you please clarify why we don't want to keep the most recent one, and remove the one made at 21:15?

I guess it's just a preference :-). When I originally developed rotate-backups I made the decision to preserve the first (oldest) backup in each time slot. For my use cases I don't consider it relevant to prefer more recent backups over less recent backups because my focus is on long term archival (versus e.g. disaster recovery).

Does it make sense to add some option (like --keep-recent) to change this behaviour and keep the latest backups?

I just released version 4.1 which adds support for the -p, --prefer-recent command line option. I've also updated the documentation to explain what the default rotation algorithm is and how to change it.

As a general (and somehow related) question, is it planned to introduce a minutely option to enable rotation if backups are made several times per hour?

I just released version 4.2 which adds support for the -M, --minutely command line option :-).

Hope this helps!

tonyo commented

@xolox Amazing, thanks a lot!