diff options
Diffstat (limited to 'lifeboat')
-rwxr-xr-x | lifeboat | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/lifeboat b/lifeboat new file mode 100755 index 0000000..244f732 --- /dev/null +++ b/lifeboat @@ -0,0 +1,41 @@ +#!/bin/sh + +set -e + +errx() { + printf "lifeboat: %s\n" "$1" >&2 + exit 1 +} + +usage() { + printf "usage: lifeboat repo [run|restic-cmd]\n" + exit 0 +} + +run_backup() { + ( + cd "$rootdir/$repo" + ./run + for i in post sync; do + test -x $i && ./$i + done + ) +} + +rootdir=${LIFEBOAT_ROOT:-"/srv/backup/lifeboat"} + +test $# -lt 2 && usage + +repo=$1 +shift + +test -d "$repo" || errx "$repo: no such repository" + +export LIFEBOAT_REPO_NAME=$repo +export RESTIC_REPOSITORY=$rootdir/$repo/repo +export RESTIC_PASSWORD_FILE=$rootdir/$repo/credentials/restic + +case "$1" in + run) run_backup;; + *) restic "$@";; +esac |