Skip to content

lomography/wolfe

Repository files navigation

Codeship Status for lomography/wolfe

Wolfe

Wolfe's purpose is to clean up database (and other) backups that encode year, month, day and hour in their filename. That's also what wolfe will look at when deciding if a file has to be removed or not. Wolfe can be configured to keep daily and monthly backups for a given timespan and will always keep one backup for every year.

Original code was written by @michaelem, tests and gemification by @srecnig. In case you're wondering, the name wolfe is a reference.

Installation

Wolfe can be installed through the usual sources: add it to your application's Gemfile or install manually through gem install.

Usage

Call wolfe from the command line and give a rule file as one single parameter.

wolfe cleanup rules.yml

Or call wolfe from within your project if you've added it to the Gemfile.

Wolfe.run_cleanup "/path/to/rules.yml"

Rules.yml

The rule file contains the information on where backups are stored, how the date metadata is encoded in the filename and how many backups to keep per timespan.

---
backup_name:
  path: /mnt/data/backups/database
  filename: 'backup-database-%{year}-%{month}-%{day}-%{hour}.tar.gz'
  one_per_day_timespan: 15.days
  one_per_month_timespan: 1.year

To configure the timespans we rely on active support's time extensions to Numeric, so something like 1.month, 2.years, etc. will work. No spaces or ruby code please.

Note: The file kept for a timespan is always the file of the last day of the timespan, e.g. the backup file kept for every year will always be the one of 31st, Dec.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/lomography/wolfe. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.