#!/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 "$rootdir/$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