diff --git a/deploy/hub/backup.sh b/deploy/hub/backup.sh index 3d09555..c1090f7 100644 --- a/deploy/hub/backup.sh +++ b/deploy/hub/backup.sh @@ -5,6 +5,11 @@ # -> ./backups/gti_fiscal_releases_YYYYmmdd_HHMMSS.tgz (release binaries + AgentRelease metadata is IN the dump above) set -eu COMPOSE="docker compose -f docker-compose.prod.yml --env-file .env" +# BACKUP_DIR (like every other setting) lives in .env, but --env-file only +# feeds the container — a plain shell script never gets it unless it loads +# the file itself. Without this, BACKUP_DIR silently falls back to ./backups +# here while the Hub's containers still read the real value from .env. +if [ -f .env ]; then set -a; . ./.env; set +a; fi DIR="${BACKUP_DIR:-./backups}" mkdir -p "$DIR" STAMP="$(date +%Y%m%d_%H%M%S)" diff --git a/deploy/hub/restore.sh b/deploy/hub/restore.sh index 06af616..373aebc 100644 --- a/deploy/hub/restore.sh +++ b/deploy/hub/restore.sh @@ -5,6 +5,9 @@ set -eu [ $# -eq 1 ] || { echo "usage: $0 " >&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 Hub database with %s. Type RESTORE to continue: " "$FILE" read -r answer diff --git a/deploy/hub/restore_releases.sh b/deploy/hub/restore_releases.sh index 74b0f31..c97e5c4 100644 --- a/deploy/hub/restore_releases.sh +++ b/deploy/hub/restore_releases.sh @@ -8,6 +8,9 @@ set -eu [ $# -eq 1 ] || { echo "usage: $0 " >&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