ansible-restic
ansible-restic copied to clipboard
replace custom wrapper scripts with runrestic
This role shouldn't reinvent the wheel and implement custom scripts for various restic functionalities. There are already many projects providing a simple to use wrapper on restic and those could be used instead.
We could use runrestic which is written in python3 and available via pip3 install runrestic. Personally I like this one as it has clear configuration and includes instrumentation to push metrics to prometheus monitoring system.
This is only an idea, but implementing this should greatly simplify second day operations and reduce role maintenance.
Going this path means that all bash/cron scripts should be removed from this repository and replaced with simple invocations of runrestic (or other software).
I think is a clever idea. I'm using a simple wrapper in bash, but something more flexible as runrestic is really appreciated.
Have you considered a separate role for installing restic itself, and (an)other role(s) for the wrapper(s)?
@davdr that's a good idea, I didn't consider it.
Have you considered a separate role for installing restic itself, and (an)other role(s) for the wrapper(s)?
Maybe just allow setting the command prefix. This would allow switching between different restic installations (e.g. package manager, docker, ...).
In my currently manual script, I am using something like:
# restic.sh
source "vars.sh"
RESTIC_LOCAL='eval restic --cache-dir "$WORKDIR/cache"'
RESTIC_DOCKER='eval docker run --rm -t
-v $WORKDIR/cache:/restic_cache
-v /home/$USER:/restic_data:ro -w /restic_data
-e RESTIC_REPOSITORY
-e RESTIC_PASSWORD
-e AWS_ACCESS_KEY_ID
-e AWS_SECRET_ACCESS_KEY
restic/restic
--cache-dir /restic_cache'
RESTIC="$RESTIC_LOCAL" # change this to RESTIC_DOCKER if you like
$RESTIC "$@"
So one can just run ./restic.sh backup --one-file-system .. It is work in progress, so adapting the docker mount when changing paths needs to be done of course, but I think you get the idea