#!/usr/bin/env bash # Runs the backup job once against the development data (SPEC ยง10.9 with RCLONE_FOLDER_ID empty: no Drive upload). # Writes kvitt-.sqlite.gz and pictures-.tar.gz into the backups folder (default infra/dev/backups/) # and checks the newest snapshot with PRAGMA integrity_check, using the backup image's own sqlite3. set -euo pipefail # shellcheck source=lib.sh . "$(dirname "$0")/lib.sh" backup_dir="$(dev_path "$(env_value KVITT_DEV_BACKUP_DIR)")" mkdir -p "$backup_dir" compose --profile backup run --rm -T backup /backup.sh latest="$(find "$backup_dir" -maxdepth 1 -name 'kvitt-*.sqlite.gz' | sort | tail -n 1)" [[ -n "$latest" ]] || { echo "backup.sh: no snapshot found in $backup_dir" >&2; exit 1; } name="$(basename "$latest")" result="$(compose --profile backup run --rm -T --entrypoint sh backup -c \ "gunzip -c '/backups/$name' > /tmp/check.sqlite && sqlite3 -batch -noheader -list /tmp/check.sqlite 'PRAGMA integrity_check'")" echo "$name: integrity_check $result" [[ "$result" == "ok" ]]