feat(db): use POSTGRES_USER in pg_backup; document it in release note
- pg_backup.sh: use the db service's POSTGRES_USER (default postgres) for the dump/drop/recreate instead of detecting the superuser at runtime, since the recipe now sets that env var; one-line the constants comment - release note: explain the in-place pg_upgrade + the POSTGRES_USER override - bump PG_BACKUP_VERSION v4 Verified on cctest: backup + restore via the hooks round-trips with POSTGRES_USER.
This commit is contained in:
2
abra.sh
2
abra.sh
@ -1,4 +1,4 @@
|
|||||||
export PG_BACKUP_VERSION=v3
|
export PG_BACKUP_VERSION=v4
|
||||||
export APP_ENTRYPOINT_VERSION=v2
|
export APP_ENTRYPOINT_VERSION=v2
|
||||||
export APP_INSTALL_SSL_VERSION=v1
|
export APP_INSTALL_SSL_VERSION=v1
|
||||||
export APP_MIGRATE_UPLOADS_VERSION=v1
|
export APP_MIGRATE_UPLOADS_VERSION=v1
|
||||||
|
|||||||
16
pg_backup.sh
16
pg_backup.sh
@ -4,23 +4,13 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# constants
|
# dump goes at the volume root so backupbot's backup.sql label finds it
|
||||||
BACKUP_FILE='/var/lib/postgresql/backup.sql'
|
BACKUP_FILE='/var/lib/postgresql/backup.sql'
|
||||||
DATADIR="${PGDATA:-/var/lib/postgresql/18/docker}"
|
DATADIR="${PGDATA:-/var/lib/postgresql/18/docker}"
|
||||||
DB_NAME="${POSTGRES_DB:-discourse}"
|
DB_NAME="${POSTGRES_DB:-discourse}"
|
||||||
|
|
||||||
# The bootstrap superuser (install user, oid 10) differs between deployments
|
# bootstrap superuser for the dump/drop/recreate; same POSTGRES_USER the db service sets
|
||||||
# (`postgres` on bitnami-origin clusters, `discourse` on others). Detect it at
|
SU="${POSTGRES_USER:-postgres}"
|
||||||
# runtime over the local trust socket rather than hard-coding a name.
|
|
||||||
detect_superuser() {
|
|
||||||
local u name
|
|
||||||
for u in discourse postgres; do
|
|
||||||
name="$(psql -U "$u" -d "$DB_NAME" -tAc 'select rolname from pg_roles where oid = 10' 2>/dev/null | tr -d '[:space:]')"
|
|
||||||
if [ -n "$name" ]; then echo "$name"; return 0; fi
|
|
||||||
done
|
|
||||||
echo postgres
|
|
||||||
}
|
|
||||||
SU="$(detect_superuser)"
|
|
||||||
|
|
||||||
function backup {
|
function backup {
|
||||||
pg_dump -U "$SU" "$DB_NAME" | gzip > "$BACKUP_FILE"
|
pg_dump -U "$SU" "$DB_NAME" | gzip > "$BACKUP_FILE"
|
||||||
|
|||||||
@ -8,3 +8,13 @@ Rename these in your app's .env (the values carry over):
|
|||||||
DISCOURSE_SMTP_USER --> DISCOURSE_SMTP_USER_NAME
|
DISCOURSE_SMTP_USER --> DISCOURSE_SMTP_USER_NAME
|
||||||
DISCOURSE_SMTP_AUTH --> DISCOURSE_SMTP_AUTHENTICATION
|
DISCOURSE_SMTP_AUTH --> DISCOURSE_SMTP_AUTHENTICATION
|
||||||
DISCOURSE_SMTP_PROTOCOL --> DISCOURSE_SMTP_ENABLE_START_TLS (takes a boolean true/false, not the old tls/ssl value, so translate it rather than copying it straight across)
|
DISCOURSE_SMTP_PROTOCOL --> DISCOURSE_SMTP_ENABLE_START_TLS (takes a boolean true/false, not the old tls/ssl value, so translate it rather than copying it straight across)
|
||||||
|
|
||||||
|
The database now runs the discourse/postgres image, which upgrades your existing
|
||||||
|
postgres cluster to a new major version in place on first boot (no dump/restore).
|
||||||
|
|
||||||
|
That upgrade runs as the cluster's bootstrap superuser ("install user"), which the
|
||||||
|
recipe sets via POSTGRES_USER, defaulting to `postgres`. This default is correct
|
||||||
|
for clusters created by this recipe and the old bitnami recipe, so most operators
|
||||||
|
need to do nothing. ONLY if your cluster was bootstrapped with a different
|
||||||
|
superuser (e.g. `discourse`) must you set POSTGRES_USER in your app's .env before
|
||||||
|
upgrading -- otherwise pg_upgrade aborts with an install-user mismatch.
|
||||||
|
|||||||
Reference in New Issue
Block a user