Install latest from the GitHub repository:
$ pip install git+https://github.com/johnowhitaker/autobackup.git
or from pypi
$ pip install autobackup
autobackup src dest
will make a copy of src
(which can be a file or
a directory) inside dir
in a folder with the current date+time, and
clean up any old backups based on the following rules:
- The most recent 5 backups are kept
- For each number of days in
--max_ages
(default is “2,14,60”) the oldest one below that age is kept.
This ensures that you have a few recent backups, one up to 2 days old, one up to 2 weeks old and one up to 2 months old.
To run this script hourly,
- Create a service file (e.g.
/etc/systemd/system/backup.service
):
[Unit]
Description=Hourly Backup Service
[Service]
ExecStart=autobackup /path/to/src /path/to/dest
[Install]
WantedBy=multi-user.target
- Create a timer file (e.g.
/etc/systemd/system/backup.timer
):
[Unit]
Description=Run Backup Service Hourly
[Timer]
OnCalendar=hourly
[Install]
WantedBy=timers.target
- Enable and start the timer:
sudo systemctl enable backup.timer
sudo systemctl start backup.timer
It takes additional args from fastcore’s xtra.globtastic, for example
you can ise -skip_folder_re '^\.\w'
to skip folders with /.
in the
name, useful for skipping cache.