Skip to main content

A wrapper script for Restic backup software that inits, creates, prunes and checks backups

Project description

python version Code style: black Travis (.com) PyPI Stackshare: runrestic PyPI - Downloads

Runrestic

runrestic is a simple Python wrapper script for the Restic backup software that initiates a backup, prunes any old backups according to a retention policy, and validates backups for consistency. The script supports specifying your settings in a declarative configuration file rather than having to put them all on the command-line, and handles common errors.

Example config

repositories = [
    "/tmp/restic-repo",
    "sftp:user@host:/srv/restic-repo",
    "s3:s3.amazonaws.com/bucket_name"
    ]

[environment]
RESTIC_PASSWORD = "CHANGEME"

[backup]
sources = [
    "/home",
    "/var"
    ]

[prune]
keep-last =  3
keep-hourly =  5

For a more comprehensive example see the example.toml or check the schema.json

Getting started

Installing runrestic and restic

To install runrestic, run the following command to download and install it:

sudo pip3 install --upgrade runrestic

You can either manually download and install Restic or you can just run runrestic and it'll try to download it for you.

Initializing and running

Once you have restic and runrestic ready, you should put a config file in on of the scanned locations, namely:

  • /etc/runrestic.toml
  • /etc/runrestic/example.toml
  • ~/.config/runrestic/example.toml

Afterwards, run

runrestic init # to initialize all the repos in `repositories`

runrestic  # without actions will do: runrestic backup prune check
# or
runrestic [action]

Certain `restic` flags like `--dry-run/-n` are built into `runrestic` as well and will be passed to restic where applicable.

If, however, you need to pass along arbitrary other flags you can now add them to the end of your runrestic call like so:

runrestic backup -- --one-file-system

Prometheus / Grafana metrics

@d-matt created a nice dashboard for Grafana here: https://grafana.com/grafana/dashboards/11064/revisions

systemd timer or cron

If you want to run runrestic automatically, say once a day, the you can configure a job runner to invoke it periodically.

systemd

If you're using systemd instead of cron to run jobs, download the sample systemd service file and the sample systemd timer file. Then, from the directory where you downloaded them:

sudo mv runrestic.service runrestic.timer /etc/systemd/system/
sudo systemctl enable runrestic.timer
sudo systemctl start runrestic.timer

cron

If you're using cron, download the sample cron file. Then, from the directory where you downloaded it:

sudo mv runrestic /etc/cron.d/runrestic
sudo chmod +x /etc/cron.d/runrestic

Changelog

  • v0.5! Expect breaking changes.
    • metrics output is a bit different
    • see new parallel and retry_* options.

Development

This project is managed with poetry

Install it if not already present:

curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python
# or
pip install --user poetry

Installing dependencies

poetry install

Running Tests

poetry run pytest

Thanks

This project was initially based on borgmatic but has since evolved into something else.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

runrestic-0.5.12.tar.gz (15.6 kB view details)

Uploaded Source

Built Distribution

runrestic-0.5.12-py3-none-any.whl (16.8 kB view details)

Uploaded Python 3

File details

Details for the file runrestic-0.5.12.tar.gz.

File metadata

  • Download URL: runrestic-0.5.12.tar.gz
  • Upload date:
  • Size: 15.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.9 CPython/3.8.5 Linux/5.4.0-51-generic

File hashes

Hashes for runrestic-0.5.12.tar.gz
Algorithm Hash digest
SHA256 3e2ad86e80e9579770a0bdc952839a338bdb0bb53d79e4c310b7905b861e036c
MD5 43afca8879e1f6589158c86c989f9f1d
BLAKE2b-256 a22ca69cd26fcf37d687e63340ffc2e1531d8f965a87c96a6f6d61f1846957fc

See more details on using hashes here.

Provenance

File details

Details for the file runrestic-0.5.12-py3-none-any.whl.

File metadata

  • Download URL: runrestic-0.5.12-py3-none-any.whl
  • Upload date:
  • Size: 16.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.9 CPython/3.8.5 Linux/5.4.0-51-generic

File hashes

Hashes for runrestic-0.5.12-py3-none-any.whl
Algorithm Hash digest
SHA256 7d2508d9a5cd3483ea339c5538d5e395a274b1a769a6d350b88a7dee441b5648
MD5 4aa155ef0bba430d8146bfdacb9e6897
BLAKE2b-256 8e6f3db9917bedcf28a39a95c06a22998f3a5355aa0d49df8a18b2d7746356db

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page