fc6126c6af
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TQd3pEP9UeN2uifbHknQ7B
21 lines
1023 B
Bash
Executable File
21 lines
1023 B
Bash
Executable File
#!/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-<UTC stamp>.sqlite.gz and pictures-<stamp>.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 ./backups)")"
|
|
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" ]] || die "no snapshot found in $backup_dir"
|
|
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" ]]
|