From 096f201c841055093d2b446db68f388f789c67e7 Mon Sep 17 00:00:00 2001 From: gti Date: Wed, 23 Sep 2026 22:52:53 -0300 Subject: [PATCH] fix: backup/restore scripts now actually read BACKUP_DIR from .env MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --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 --- deploy/hub/backup.sh | 5 +++++ deploy/hub/restore.sh | 3 +++ deploy/hub/restore_releases.sh | 3 +++ 3 files changed, 11 insertions(+) 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