Auto-discover databases from postgres — remove static BACKUP_DATABASES list

This commit is contained in:
jtricerolph 2026-07-14 11:49:49 +00:00
parent 5e7093c115
commit c72ebdf79a
3 changed files with 8 additions and 2 deletions

View file

@ -92,6 +92,14 @@ done
# ── PostgreSQL dumps ──────────────────────────────────────────────────────────
log "PostgreSQL backups..."
BACKUP_DATABASES=$(PGPASSWORD="$PG_SUPERPASS" psql -h "$PG_HOST" -U postgres -t -A -c \
"SELECT datname FROM pg_database WHERE datistemplate = false AND datname != 'postgres' ORDER BY datname" \
2>/dev/null) || true
if [ -z "$BACKUP_DATABASES" ]; then
err "Could not list databases from postgres"
finish "error" "Could not connect to postgres to list databases"
exit 1
fi
for DB in $BACKUP_DATABASES; do
log " ${DB}..."
TARGET="${NC_DAV}/postgres/daily/${DB}_${TIMESTAMP}.sql.gz"