Use cron to rotate backup files!
Project description
cronicle
/ˈkɹɒnɪkəl/ :
n. a factual written account of important events in the order of their occurrence
n. software to archive the N most recent backups of a file in a folder named after the job frequency. Recommended use is to trigger it via a cron job.
Originally, cronicle has been conceived as a solution to this particular serverfault question : How to keep: daily backups for a week, weekly for a month, monthly for a year, and yearly after that.
Features
simplicity: add one line to your crontab and you’re done
files rotation: keep the N most recent versions of a file
space efficient: use symlinks in target directories to store a single occurence of each backup instead of performing copies. When removing a link, remove the underlying file if no other link point to it.
Usage
In order to manage a file backups with cronicle, you must have a section in the config.yaml that matches the backups names. Under it you can then define values (number of archives to keep) for the five kinds of periodic archives : hourly, daily, weekly, monthly, yearly.
Or define a custom periodicity using the pipe syntax eg bimonthly|60: 3 to keep archives every two months over the last six months.
Example
If you have dumps of a database in a ~/dumps directory named like mydb-20170101.dump, mydb-20170102.dump, and want to keep each dump for 7 days plus go back up to two months ; a working ${HOME}/.config/cronicle/config.yaml content would be :
/home/johndoe/dumps/mydb-*.dump: daily: 7 monthly: 2
Next cronicle call will result in the creation of folders DAILY and MONTHLY in /home/johndoe/dumps/, each folder containing symlinks to the .dump files.
Installation
cronicle is written for Python 2.7 and Python 3, is tested on Linux and Mac OS X.
Install with pip via pip install git+https://github.com/Kraymer/cronicle.git command.
cron triggering
For a no-brainer use, I recommend to run cronicle via cron, just after the command in charge of performing the backup. A crontab example :
@daily pg_dump -Fc mydb > /home/johndoe/dumps/mydb-`date +%F`.dump @daily cronicle -r /home/johndoe/dumps/mydb-`date +%F`.dump
If used with the config.yaml as defined in the previous section, this daily call to cronicle guarantees that you will keep at most 9 database dumps (7 latest daily + 2 monthly).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file cronicle-0.4.0.tar.gz
.
File metadata
- Download URL: cronicle-0.4.0.tar.gz
- Upload date:
- Size: 9.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 26493e5b8ce0e7d8f393db1d010fca3e70ea0f395e46ff777a99b42e911903b0 |
|
MD5 | 7485ac16890abe971581301380282894 |
|
BLAKE2b-256 | 519c87a117ff025e790193a4bfb51214a904238ba2be0693ddc11565f2a2ecc1 |
File details
Details for the file cronicle-0.4.0-py3-none-any.whl
.
File metadata
- Download URL: cronicle-0.4.0-py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0d736f489ace8776ef8c2fc1d9420f6c807178876d0df09f4d8a492ae56cdd01 |
|
MD5 | effaab063be0738c4045b9610c2a4aef |
|
BLAKE2b-256 | 9e2da97568453bed38d02ed32485e523677d0a4b978f0b0e10dde4b6e0c55e21 |