GrandFatherSon

Grandfather-father-son backup rotation calculator
Download

GrandFatherSon Ranking & Summary

Advertisement

  • Rating:
  • License:
  • BSD License
  • Price:
  • FREE
  • Publisher Name:
  • Ecometrica
  • Publisher web site:
  • http://github.com/ecometrica/

GrandFatherSon Tags


GrandFatherSon Description

GrandFatherSon is a backup rotation calculator module that implements the grandfather-father-son rotation scheme.This is usually done by keeping a certain number of daily, weekly, and monthly backups. Older backups should be removed to reduce the amount of space used.UsageThis module expects either datetime.date or datetime.datetime objects as inputs. As an example, let's assume you have daily backups for the all of year 1999 that need rotating:>>> import datetime>>> start_date = datetime.date(1999, 1, 1)>>> end_date = datetime.date(1999, 12, 31)>>> backups = >>> backupsLet's say that full backups are taken every Saturday, with incremental backups done daily. A week, or 7 days, of incremental backups should be kept. A months, or 4 weeks, of full backups are kept. In addition, for three months, the first full backup is kept for each month, with the others discarded.It's the last day of the year and you want to figure out which backups need to be pruned:>>> now = datetime.date(1999, 12, 31)To see which files will be preserved, use the dates_to_keep function:>>> from grandfatherson import dates_to_keep, SATURDAY>>> sorted(dates_to_keep(backups, days=7, weeks=4, months=3,... firstweekday=SATURDAY, now=now))If you leave off the now argument, it will default to using datetime.datetime.now().To see which files should be deleted, use the dates_to_delete function:>>> from grandfatherson import dates_to_keep, SATURDAY>>> sorted(dates_to_delete(backups, days=7, weeks=4, months=3,... firstweekday=SATURDAY, now=now))Finally, if you need to rotate backups that have timestamps in datetime format, you can use the corresponding to_keep and to_delete functions:>>> now = datetime.datetime(1999, 12, 31, 23, 59, 59)>>> start_datetime = datetime.datetime(1999, 12, 31, 0, 0, 0)>>> end_datetime = datetime.datetime(1999, 12, 31, 23, 59, 59)>>> backups = >>> backups>>> from grandfatherson import to_keep>>> sorted(to_keep(backups, hours=2, minutes=10, seconds=10, now=now))>>> from grandfatherson import to_delete>>> sorted(to_delete(backups, hours=2, minutes=10, seconds=10, now=now))Product's homepage


GrandFatherSon Related Software