docs(forte-drop-pg-backup): restore runbook lists and downloads with rclone
scan.yaml / test (pull_request) Successful in 35s

The runbook ran its listing and download pods with the mc image that can no
longer be pulled, so the recovery path was broken too. Same image and env-var
remote as the backup job. From the ai-review on the PR.
This commit is contained in:
jorgenseeyou
2026-11-24 12:53:20 +01:00
parent 4513a31975
commit a30d9c1071
@@ -29,10 +29,11 @@ kubectl -n forte-drop get pods -l app.kubernetes.io/name=postgresql
## List available backups ## List available backups
```bash ```bash
# Run an ephemeral mc pod with the app's S3 creds: # Run an ephemeral rclone pod with the app's S3 creds (the backup job's image
kubectl -n forte-drop run mc-list --rm -it --restart=Never \ # and env-var remote; the mc image used here before can no longer be pulled):
--image=quay.io/minio/mc:RELEASE.2024-11-21T17-21-54Z \ kubectl -n forte-drop run rclone-list --rm -it --restart=Never \
--overrides='{"spec":{"containers":[{"name":"mc","image":"quay.io/minio/mc:RELEASE.2024-11-21T17-21-54Z","command":["sh","-c","mc alias set obj \"$S3_ENDPOINT\" \"$S3_KEY\" \"$S3_SECRET\" >/dev/null && mc ls obj/drops/_pgbackups/"],"envFrom":[{"secretRef":{"name":"forte-drop-secrets"}}]}]}}' --image=rclone/rclone:1.75.2 \
--overrides='{"spec":{"containers":[{"name":"rclone","image":"rclone/rclone:1.75.2","command":["sh","-c","export RCLONE_CONFIG_S3_TYPE=s3 RCLONE_CONFIG_S3_PROVIDER=Other RCLONE_CONFIG_S3_ENDPOINT=\"$S3_ENDPOINT\" RCLONE_CONFIG_S3_ACCESS_KEY_ID=\"$S3_KEY\" RCLONE_CONFIG_S3_SECRET_ACCESS_KEY=\"$S3_SECRET\" HOME=/tmp; rclone lsl s3:drops/_pgbackups/ 2>/dev/null"],"envFrom":[{"secretRef":{"name":"forte-drop-secrets"}}]}]}}'
``` ```
## Manually trigger a backup (before risky changes) ## Manually trigger a backup (before risky changes)
@@ -53,41 +54,17 @@ kubectl -n forte-drop logs -l app.kubernetes.io/component=backup --tail=40
List backups (above), choose `forte-drop-<TS>.sql.gz`. List backups (above), choose `forte-drop-<TS>.sql.gz`.
### 2. Run a restore pod that pulls the dump and pipes it into Postgres ### 2. Download the dump, then pipe it into Postgres
```bash ```bash
DUMP="forte-drop-20260530T020000Z.sql.gz" # <-- set to the chosen file DUMP="forte-drop-20260530T020000Z.sql.gz" # <-- set to the chosen file
kubectl -n forte-drop run pg-restore --rm -it --restart=Never \
--image=postgres:16-alpine \
--overrides='{
"spec": {
"containers": [{
"name": "restore",
"image": "postgres:16-alpine",
"command": ["sh","-c","set -euo pipefail; \
apk add --no-cache curl >/dev/null; \
# download via mc is simpler — use a 2-step instead (see note). \
echo placeholder"],
"envFrom": [
{"secretRef":{"name":"forte-drop-pg-creds"}},
{"secretRef":{"name":"forte-drop-secrets"}}
]
}]
}
}'
```
**Simpler 2-pod approach (recommended — avoids cramming mc + psql in one image):**
```bash
DUMP="forte-drop-20260530T020000Z.sql.gz"
# (a) Download the dump from object storage to a local file: # (a) Download the dump from object storage to a local file:
kubectl -n forte-drop run mc-get --rm -it --restart=Never \ kubectl -n forte-drop run rclone-get --rm -i --restart=Never --quiet \
--image=quay.io/minio/mc:RELEASE.2024-11-21T17-21-54Z \ --image=rclone/rclone:1.75.2 \
--overrides='{"spec":{"containers":[{"name":"mc","image":"quay.io/minio/mc:RELEASE.2024-11-21T17-21-54Z","command":["sh","-c","mc alias set obj \"$S3_ENDPOINT\" \"$S3_KEY\" \"$S3_SECRET\" >/dev/null && mc cat obj/drops/_pgbackups/'"$DUMP"'"],"envFrom":[{"secretRef":{"name":"forte-drop-secrets"}}]}]}}' \ --overrides='{"spec":{"containers":[{"name":"rclone","image":"rclone/rclone:1.75.2","command":["sh","-c","export RCLONE_CONFIG_S3_TYPE=s3 RCLONE_CONFIG_S3_PROVIDER=Other RCLONE_CONFIG_S3_ENDPOINT=\"$S3_ENDPOINT\" RCLONE_CONFIG_S3_ACCESS_KEY_ID=\"$S3_KEY\" RCLONE_CONFIG_S3_SECRET_ACCESS_KEY=\"$S3_SECRET\" HOME=/tmp; rclone cat s3:drops/_pgbackups/'"$DUMP"' 2>/dev/null"],"envFrom":[{"secretRef":{"name":"forte-drop-secrets"}}]}]}}' \
> /tmp/$DUMP > /tmp/$DUMP
gunzip -t /tmp/$DUMP && ls -lh /tmp/$DUMP # must pass before you go on
# (b) Pipe it into the live Postgres via the service: # (b) Pipe it into the live Postgres via the service:
gunzip -c /tmp/$DUMP | kubectl -n forte-drop run pg-restore --rm -i --restart=Never \ gunzip -c /tmp/$DUMP | kubectl -n forte-drop run pg-restore --rm -i --restart=Never \
@@ -127,7 +104,7 @@ UpCloud-managed/replicated, so no separate file backup is configured. If a
file-level backup is later required, mirror the bucket to a second bucket/region: file-level backup is later required, mirror the bucket to a second bucket/region:
```bash ```bash
mc mirror --overwrite obj/drops/ backup-target/drops-mirror/ rclone sync s3:drops/ backup-target:drops-mirror/ --exclude "_pgbackups/**"
``` ```
(Exclude `_pgbackups/` from the app-data mirror if you split them.) (Exclude `_pgbackups/` from the app-data mirror if you split them.)