You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`BACKUP_DATABASE_URLS` runs **`pg_dump`** per database. That does **not** include cluster-wide objects: roles, role memberships, database-level defaults, tablespaces, and similar metadata. To capture those, the backup image runs **`pg_dumpall --globals-only`** when configured (see **`PG_GLOBALS_URL`** below).
39
+
40
+
Without **`PG_GLOBALS_URL`**, the service may still attempt a globals dump using credentials from the **first**`postgresql://…` URL discovered under `PARENT_DIR`. Those URLs are usually **application users**, not superusers, so the globals step is often **skipped** (insufficient privileges). For reliable globals backups, set **`PG_GLOBALS_URL`** to a **superuser** connection.
41
+
42
+
### Creating a dedicated PostgreSQL superuser for globals backup
43
+
44
+
Use a **dedicated** superuser role (least surprise when rotating app passwords). From the host, with the PostgreSQL container running:
45
+
46
+
```bash
47
+
cd apps/postgresql
48
+
# load admin user from compose env (default superuser in the image)
In **`psql`**, create a login role used only for backups (pick a strong password, e.g. from `pwgen 32 1`):
60
+
61
+
```sql
62
+
CREATE ROLE db_backup_globals WITH LOGIN SUPERUSER PASSWORD 'replace-with-strong-password';
63
+
```
64
+
65
+
**Security:** treat this password like root DB access. Restrict who can read **`db-backup`**`.env` and your secrets store.
66
+
67
+
You can instead reuse the cluster’s bootstrap superuser (`POSTGRES_USER` / `POSTGRES_PASSWORD` from `apps/postgresql/.env`) in **`PG_GLOBALS_URL`**, but rotating that password is more disruptive than rotating a dedicated backup role.
68
+
69
+
### `PG_GLOBALS_URL` (db-backup `.env`)
70
+
71
+
Set this in **`apps/db-backup/.env`** (not in per-app `.env` files). The [hackstack-db-backup](https://github.com/romkey/hackstack-db-backup) image reads it each backup cycle.
**Output file:**`DEST_DIR/postgresql/backup-globals-postgresql-5432-<timestamp>.sql.bz2` (compressed with the same retention logic as other backups under that folder).
88
+
89
+
If **`PG_GLOBALS_URL`** is unset, globals backup is only attempted with credentials inferred from discovered app URLs and may be skipped if those users are not superusers.
90
+
91
+
**Special characters in passwords** must be **URL-encoded** in `PG_GLOBALS_URL` (e.g. `@` → `%40`, `:` → `%3A`).
92
+
36
93
## Configuration
37
94
38
95
### Environment Variables
@@ -57,6 +114,7 @@ cp .env.example .env
57
114
|`BACKUP_RETAIN_MONTHLY`| No |`6`| Monthly backups to keep |
58
115
|`BACKUP_RETAIN_YEARLY`| No |`6`| Yearly backups to keep |
59
116
|`IMAGE_VERSION`| No |`latest`| Docker image tag |
117
+
|`PG_GLOBALS_URL`| No | — |`postgresql://` URL with a **superuser** used for `pg_dumpall --globals-only` (roles / cluster metadata). See [PostgreSQL globals](#postgresql-per-database-vs-cluster-globals). |
0 commit comments