Files
restic-automatic-backup-sch…/usr/local/sbin/restic_check.sh
T
Erik Westrup f4b90c2499 Add RESTIC_VERBOSITY_LEVEL
Fixes #50
2022-02-01 16:19:05 +01:00

28 lines
938 B
Bash

#!/usr/bin/env bash
# Check the backups made with restic to Backblaze B2 for errors.
# See restic_backup.sh on how this script is run (as it's analogous for this script).
# Exit on failure, pipe failure
set -e -o pipefail
# Clean up lock if we are killed.
# If killed by systemd, like $(systemctl stop restic), then it kills the whole cgroup and all it's subprocesses.
# However if we kill this script ourselves, we need this trap that kills all subprocesses manually.
exit_hook() {
echo "In exit_hook(), being killed" >&2
jobs -p | xargs kill
restic unlock
}
trap exit_hook INT TERM
# Remove locks from other stale processes to keep the automated backup running.
# NOTE nope, don't unlock like restic_backup.sh. restic_backup.sh should take precedence over this script.
#restic unlock &
#wait $!
# Check repository for errors.
restic check \
--option b2.connections=$B2_CONNECTIONS \
--verbose=$RESTIC_VERBOSITY_LEVEL &
wait $!