Skip to main content

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

Project description

Overview

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.

Here's an example config file:

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

[environment]
RESTIC_PASSWORD = "CHANGEME"
# or RESTIC_PASSWORD_FILE = "/path/to/file"
# see https://restic.readthedocs.io/en/latest/040_backup.html#environment-variables 
# especially if you need to set environment variables like AWS_ACCESS_KEY_ID and such

[location]
source_directories = [
    "/home",
    "/var"
    ]

# exclude_patterns = []
# exclude_files = []
# https://restic.readthedocs.io/en/stable/040_backup.html#including-and-excluding-files

[retention]
keep-last =  3
keep-hourly =  5
keep-weekly = 10
keep-monthly = 30
# https://restic.readthedocs.io/en/latest/060_forget.html#removing-snapshots-according-to-a-policy

[consistency]
checks = ["check-unused", "read-data"]
# https://restic.readthedocs.io/en/stable/045_working_with_repos.html#checking-a-repo-s-integrity-and-consistency

[metrics.prometheus]
path = "/var/lib/node_exporter/textfile_collector/runrestic.prom"

Installation

To get up and running, first install Restic.

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

sudo pip3 install --upgrade runrestic

Note that your pip binary may have a different name than pip3. Make sure you're using Python 3, as runrestic does not support Python 2.

Autopilot

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

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

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

Thanks

Much of this project is copy and paste from borgmatic.

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.1.1.tar.gz (7.9 kB view hashes)

Uploaded Source

Built Distribution

runrestic-0.1.1-py3-none-any.whl (22.6 kB view hashes)

Uploaded Python 3

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