Package: runrestic
Runresticrunrestic is a simple Python wrapper script for theResticbackup 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 configrepositories=["/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=3keep-hourly=5Alternatively you can also just use JSON. For a more comprehensive example see theexample.tomlor check theschema.jsonGetting startedInstalling runrestic and resticTo installrunrestic, run the following command to download and install it:sudopip3install--upgraderunresticYou can either manually download and install [Restic](https://restic.net/) or you can just run `runrestic` and it'll try to download it for you.Initializing and runningOnce you haveresticandrunresticready, you should put a config file in on of the scanned locations, namely:/etc/runrestic.toml/etc/runrestic/example.toml~/.config/runrestic/example.toml/etc/runrestic.json/etc/runrestic/example.json~/.config/runrestic/example.jsonAfterwards, runrunresticinit# to initialize all the repos in `repositories`runrestic# without actions will do: runrestic backup prune check# orrunrestic[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 yourrunresticcall like so:runresticbackup----one-file-systemLogs for restic and hooksThe output ofresticand the configured pre/post-hooks is added to therunresticlogs at the level defined in[execution] proc_log_level(default: DEBUG), which can be overwritten with the CLI option-p/--proc-log-level.For process log levels greater thanINFOthe output of file names is suppressed and for log levels greater than WARNINGresticis executed with the--quietoption. If the process log level is set toDEBUG, then restic is executed
with the--verboseoption.It is also possible to addresticprogress messages to the logs by using the CLI option--show-progress INTERVALwhere theINTERVALis the number of seconds between the progress messages.Restic shellTo use the options defined inrunresticwithrestic(e.g. for a backup restore), you can use theshellaction:runresticshellIf you are using multiple repositories or configurations, you can select one now.Prometheus / Grafana metrics@d-mattcreated a nice dashboard for Grafana here:https://grafana.com/grafana/dashboards/11064/revisionssystemd timer or cronIf you want to run runrestic automatically, say once a day, the you can
configure a job runner to invoke it periodically.systemdIf you're using systemd instead of cron to run jobs, download thesample systemd service fileand thesample systemd timer file.
Then, from the directory where you downloaded them:sudomvrunrestic.servicerunrestic.timer/etc/systemd/system/
sudosystemctlenablerunrestic.timer
sudosystemctlstartrunrestic.timercronIf you're using cron, download thesample cron file.
Then, from the directory where you downloaded it:sudomvrunrestic/etc/cron.d/runrestic
sudochmod+x/etc/cron.d/runresticChangelogv0.5.28Allow jsonschema >= 4.0v0.5.27Fix output parsing for new restic version 0.14.0Introduce failsafe output parser which supports default valuesv0.5.26Add output messages fromresticand pre/post-hook commands to runrestic logs.New CLI argument--show-progress INTERVALfor the restic progress update interval in seconds (default None)v0.5.25Drop support for Python 3.6, add support for Python 3.9 and 3.10, update dependenciesv0.5.24Exit the script with returncode = 1 if there was an error in any of the tasksv0.5.23support JSON config files.v0.5.21fix issue where "check" does not count towards overall "errors"-metricv0.5! Expect breaking changes.metrics output is a bit differentsee newparallelandretry_*options.Ansible@tabic wrote an ansible role, you can find it here:https://github.com/outwire/ansible-role-restic. (I have neither checked nor tested it.)DevelopmentThis project is managed withpoetryInstall itif not already present:curl-sSLhttps://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py|python# orpipinstall--userpoetryInstalling dependenciespoetryinstallRunning TestspoetryrunpytestUsing VScode devcontainerThe project contains a.devcontainerfolder with the settings for VScode todevelop inside container. The Python virtual environment
created by poetry is stored outside the container in the projects path.virtualenvsso that it survives container rebuilds.The Ubuntu 22.04 based container uses Python 3.10 as system version and includes minimal Python 3.7, 3.8 and 3.9 versions
for creating virtual environments in any of those versions.It is possible to switch the Python version used bypoetrywith the commandpoetry use <version>,
seepoetry managing environmentsfor more details.ThanksThis project was initially based onborgmaticbut has since evolved into something else.