M23: automate verified database backups
This commit is contained in:
Executable
+12
@@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
destination="${1:-backups/postgres}"
|
||||
case "$destination" in ""|"/"|".") echo "Unsafe backup destination: $destination" >&2; exit 1;; esac
|
||||
latest="$(find "$destination" -maxdepth 1 -type f -name 'mobilityops-*.dump' | sort -r | head -n 1)"
|
||||
[ -n "$latest" ] || { echo "No MobilityOps backup found" >&2; exit 1; }
|
||||
[ -f "$latest.sha256" ] || { echo "Checksum missing for $latest" >&2; exit 1; }
|
||||
(cd "$destination" && sha256sum -c "$(basename "$latest.sha256")")
|
||||
docker compose -p "${COMPOSE_PROJECT_NAME:-mobilityops}" \
|
||||
-f compose.yaml -f compose.unraid.yaml exec -T db pg_restore --list < "$latest" > /dev/null
|
||||
printf 'Verified: %s\n' "$latest"
|
||||
Reference in New Issue
Block a user