Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/johnowhitaker/autobackup

Automatically create backups of a directory
https://github.com/johnowhitaker/autobackup

Last synced: about 2 months ago
JSON representation

Automatically create backups of a directory

Awesome Lists containing this project

README

        

# autobackup

## Usage

### Installation

Install latest from the GitHub
[repository](https://github.com/johnowhitaker/autobackup):

``` sh
$ pip install git+https://github.com/johnowhitaker/autobackup.git
```

or from [pypi](https://pypi.org/project/autobackup/)

``` sh
$ pip install autobackup
```

## How to use

`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,

1. 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

2. Create a timer file (e.g. `/etc/systemd/system/backup.timer`):

[Unit]
Description=Run Backup Service Hourly

[Timer]
OnCalendar=hourly

[Install]
WantedBy=timers.target

3. Enable and start the timer:

sudo systemctl enable backup.timer
sudo systemctl start backup.timer