Giter Club home page Giter Club logo

runrestic's Introduction

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.

Thanks

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

runrestic's People

Contributors

andreasnuesslein avatar gdhordain avatar d-matt avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.