fix: backup/restore scripts now actually read BACKUP_DIR from .env

--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>
This commit is contained in:
gti
2026-09-23 22:52:53 -03:00
co-authored by Claude Sonnet 5
parent d884d41db5
commit 096f201c84
3 changed files with 11 additions and 0 deletions
+5
View File
@@ -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)"
+3
View File
@@ -5,6 +5,9 @@ set -eu
[ $# -eq 1 ] || { echo "usage: $0 <backup.dump>" >&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
+3
View File
@@ -8,6 +8,9 @@ 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