Skip to content
Repos

TOSV

Shell 787 B15 lines Opens in site

Directory Raw Download

#!/bin/bash
# backup-verify: restore latest vault snapshot into an empty dir and check it.
# Usage: backup-verify.sh <empty-dest-dir>
set -u
command -v restic >/dev/null 2>&1 || { echo "restic not installed"; exit 3; }
DEST="${1:?usage: backup-verify.sh <empty-dest-dir>}"
[ -e "$DEST" ] && { echo "dest must not exist: $DEST"; exit 2; }
mkdir -p "$DEST"
REPO="${TOSV_RESTIC_REPO:?set TOSV_RESTIC_REPO}"
export RESTIC_REPOSITORY="$REPO" RESTIC_PASSWORD_FILE="${TOSV_RESTIC_PASSFILE:?set TOSV_RESTIC_PASSFILE}"
restic restore latest --target "$DEST" --tag tosv
F="$DEST$(cd "${TOSV_DATA_DIR:-$PWD}" && pwd)"
[ -f "$F/tosv_db.txt" ] || { echo "VERIFY-FAIL: no DB in restore"; exit 1; }
[ -d "$F/tosv_store" ] || { echo "VERIFY-FAIL: no store in restore"; exit 1; }
echo "RESTORE-OK $DEST"
16.5ms