I wrote an archive rotation script


I just released an archive rotation script on github. It’s here: https://github.com/maxharp3r/archive-rotator I use this script to rotate a number of backup archives that are the result of nightly db dumps and directory tar | gzips.

There are a few things that motivated me to write this script:

  • It’s stateless. The script uses a naming convention to track its state, so it doesn’t generate extra junk in my directories.
  • It doesn’t use configuration files. Again, no extra junk.
  • It doesn’t rely on dates or times. It can be used as a daily job just as easily as it can be used weekly, monthly, or every minute.
  • It supports three useful algorithms for managing the disk space/history tradeoff. These algorithms are: FIFO (simple rotation), Tower of Hanoi, and a tiered algorithm that is a more configurable version of grandfather-father-son.

My design is opinionated. If you’re interested in alternatives, here’s one that has different opinions, but is also cool: https://github.com/adamfeuer/rotate-backups

Photo credit: http://www.flickr.com/photos/benoit_d/4136716652/