Dump PostgreSQL pods whatever image they run

The dump assumed the official image's environment and the postgres
superuser. Bitnami keeps its passwords in files, and on this cluster the
superuser password no longer matches the database, so the Gitea database
backup would have failed. The collector now resolves the credentials from
either layout, probes them before dumping so a failed login cannot
truncate the archive, and falls back to a single-database dump when only
the application user works. Verified against both databases on the server.

Also adds the Nextcloud manifest that installs it on the cluster.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Dennis Nemec
2026-09-03 21:32:43 +02:00
parent 8f5bc1755e
commit 1339ae864e
3 changed files with 284 additions and 4 deletions

View File

@ -14,15 +14,33 @@ Enter the passphrase of the strategy when prompted.
## 2. Restore per source type
### PostgreSQL dump (`.sql.gz`, produced by `pg_dumpall` inside the pod)
### PostgreSQL dump (`.sql.gz`)
The archive is one of two shapes, depending on which credentials the pod exposes. The first
line says which one:
- `-- PostgreSQL database cluster dump` — every database and all roles, taken with the
superuser. Restore it into the cluster.
- `-- PostgreSQL database dump` — a single database, taken with the application user because
the superuser password of the pod did not work. Restore it into that database.
Stop the application first, for example
`microk8s kubectl scale deploy/gitea -n gitea --replicas=0`, and start it again afterwards.
Cluster dump:
```bash
gunzip -c nextcloud-db_*.sql.gz | microk8s kubectl exec -i -n nextcloud nextcloud-postgresql-0 -- \
sh -c 'PGPASSWORD="$POSTGRES_PASSWORD" psql -U "$POSTGRES_USER" -d postgres'
```
Single database:
```bash
gunzip -c gitea-db_*.sql.gz | microk8s kubectl exec -i -n gitea gitea-postgresql-0 -- \
sh -c 'PGPASSWORD="$POSTGRES_PASSWORD" psql -U postgres'
sh -c 'PGPASSWORD=$(cat "$POSTGRES_PASSWORD_FILE") psql -U "$POSTGRES_USER" -d "$POSTGRES_DATABASE"'
```
Stop Gitea first (`microk8s kubectl scale deploy/gitea -n gitea --replicas=0`) and start it again afterwards.
### Persistent volume (`.tar.gz` of the hostpath directory)
Find the directory of the PVC on the host and unpack into it: