19 lines
688 B
Bash
Executable File
19 lines
688 B
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
|
|
backup_root="${ASSISTANT_BACKUP_DIR:-/home/m/assistant-backups/postgres}"
|
|
verify_script="${ASSISTANT_RESTORE_VERIFY_SCRIPT:-/home/m/assistant-ops/verify-postgres-restore.sh}"
|
|
|
|
latest="$(find "$backup_root" -mindepth 1 -maxdepth 1 -type d -regextype posix-extended -regex '.*/[0-9]{8}T[0-9]{6}Z$' -printf '%f\n' | sort | tail -n 1)"
|
|
if [ -z "$latest" ]; then
|
|
echo "No completed PostgreSQL backup found in $backup_root" >&2
|
|
exit 1
|
|
fi
|
|
|
|
case "$latest" in
|
|
[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]T[0-9][0-9][0-9][0-9][0-9][0-9]Z) ;;
|
|
*) echo "Selected backup directory has invalid timestamp: $latest" >&2; exit 1 ;;
|
|
esac
|
|
|
|
exec "$verify_script" "$backup_root/$latest"
|