dotfiles/restic-backup/.local/bin/restic-backup

24 lines
598 B
Bash
Executable file

#!/usr/bin/env bash
set -e
source ~/.config/restic-backup/config.sh
cleanup() {
pass gocrypt close || true > /dev/null 2>&1
}
trap cleanup EXIT
pass gocrypt close > /dev/null 2>&1 || true
PASS_GOCRYPT_CLOSE_TIMEOUT=2147483648 pass gocrypt open
for dir in ${RESTIC_BACKUP_SUBVOL_PATHS[@]}; do
parent="$(dirname $dir)"
snap="$parent/$(basename $dir)-restic"
echo "snap = $snap"
sudo btrfs subvol delete "$snap" > /dev/null 2>&1 || true
sudo btrfs subvol snap "$dir" "$snap"
restic-wrapper --verbose backup --exclude-caches "$snap"
sudo btrfs subvol delete "$snap" || true
done