Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

docs(backup): keep the PostgreSQL password out of DATABASE_URL

Yudhi Armyndharisedb78b2ae8a0
diff --git a/docs/11-operational-runbooks.md b/docs/11-operational-runbooks.md
index d6cbfbd1d..ba3b402ad 100644
--- a/docs/11-operational-runbooks.md
+++ b/docs/11-operational-runbooks.md
@@ -601,10 +601,12 @@ User-managed files outside that list (for example the project-level `.env`) must
# Run from the repo root (database defaults are ./data/...; state dirs follow OPENWA_DATA_DIR):
./scripts/backup.sh
-# Customize via environment:
+# Customize via environment. Keep the password out of DATABASE_URL: the URL is passed to pg_dump as
+# an argument, which every local user can read in the process list while the dump runs. pg_dump
+# takes it from PGPASSWORD (or ~/.pgpass) instead:
OPENWA_DATA_DIR=/srv/openwa/data \
BACKUP_DIR=/backups/openwa \
- DATABASE_TYPE=postgres DATABASE_URL=postgres://user:pass@host:5432/openwa \
+ DATABASE_TYPE=postgres DATABASE_URL=postgres://user@host:5432/openwa PGPASSWORD='<password>' \
./scripts/backup.sh
```
diff --git a/scripts/backup.sh b/scripts/backup.sh
index db77d9b35..01731b51f 100755
--- a/scripts/backup.sh
+++ b/scripts/backup.sh
@@ -33,6 +33,11 @@
# SESSION_DATA_PATH, BAILEYS_AUTH_DIR, STORAGE_LOCAL_PATH, PLUGINS_DIR
# override the corresponding state directories
# For postgres: DATABASE_URL, or DATABASE_HOST/PORT/USERNAME/PASSWORD/NAME
+# DATABASE_URL is read by this script only (the app uses the DATABASE_* keys)
+# and wins over them when set. It is passed to pg_dump as an argument, which
+# other local users can read in the process list, so leave the password out of
+# it and supply PGPASSWORD or ~/.pgpass instead; the DATABASE_* path already
+# passes DATABASE_PASSWORD through PGPASSWORD.
#
# Failure policy: a missing source database is FATAL (no silent empty backup), and the finished
# archive must contain every configured database or it is deleted and the run fails. When the