--env-file only feeds the containers; a plain shell script never saw BACKUP_DIR, so it silently fell back to ./backups while the Hub itself used the real value from .env. Found in production: postgres's /backups bind mount was still pinned to a directory orphaned by an earlier git-archive swap (mv gti-fiscal gti-fiscal_old && mv gti-fiscal_new gti-fiscal — Linux bind mounts follow the original dentry, not the path string), so every backup.sh run had been silently landing dumps nobody could find at the live path. Fixed by pointing BACKUP_DIR at a stable absolute path outside the deploy tree and recreating postgres once to pick it up; verified with a real ./backup.sh run in production. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
21 lines
1.2 KiB
Bash
21 lines
1.2 KiB
Bash
#!/usr/bin/env sh
|
|
# Restore the release-storage volume (backup.sh's *.tgz) into the Hub.
|
|
# DESTRUCTIVE for the current release binaries: asks for confirmation. The
|
|
# AgentRelease metadata (version/sha256/status) lives in Postgres, not here —
|
|
# restore that separately with restore.sh from a dump taken around the same time.
|
|
# ./restore_releases.sh ./backups/gti_fiscal_releases_20260923_224551.tgz
|
|
set -eu
|
|
[ $# -eq 1 ] || { echo "usage: $0 <releases_backup.tgz>" >&2; exit 2; }
|
|
FILE="$(basename "$1")"
|
|
COMPOSE="docker compose -f docker-compose.prod.yml --env-file .env"
|
|
# See backup.sh: BACKUP_DIR lives in .env, which --env-file only feeds to
|
|
# the container, not to this shell script.
|
|
if [ -f .env ]; then set -a; . ./.env; set +a; fi
|
|
[ -s "${BACKUP_DIR:-./backups}/$FILE" ] || { echo "backup not found in ${BACKUP_DIR:-./backups}: $FILE" >&2; exit 1; }
|
|
printf "This REPLACES the current release-storage contents with %s. Type RESTORE to continue: " "$FILE"
|
|
read -r answer
|
|
[ "$answer" = "RESTORE" ] || { echo "aborted"; exit 1; }
|
|
$COMPOSE exec -T fiscal-hub sh -c 'rm -rf /app/data/releases && mkdir -p /app/data/releases'
|
|
$COMPOSE exec -T fiscal-hub tar -C /app/data -xz < "${BACKUP_DIR:-./backups}/$FILE"
|
|
echo "restore ok: $FILE"
|