apps(farrisilk): document backup schedule/restore/RPO + the filestore gap with measured evidence
This commit is contained in:
parent
03fb50c3d7
commit
96404c96e1
2 changed files with 163 additions and 16 deletions
|
|
@ -142,21 +142,166 @@ created over XML-RPC appears as a 697-byte file at exactly that path.
|
|||
are files. A database-only restore comes back looking healthy and every
|
||||
attachment, image and rendered artefact is gone.
|
||||
|
||||
## Backups — the gap, stated plainly
|
||||
## Backups — the client's shape, implemented and measured
|
||||
|
||||
There are **no backups of this stack in the cluster**, and none are being added
|
||||
by this card.
|
||||
`backup.yaml` implements the **standard shape of the client's stated practice**
|
||||
(a bash script on cron that dumps the database). It is *not* a copy of the
|
||||
client's script — theirs has not been seen yet (Week 3 read-only audit item) —
|
||||
and the label matters: everything below is what the *described* method does and
|
||||
does not give you.
|
||||
|
||||
The client's practice is a **cron-driven `pg_dump` of the database only** — no
|
||||
barman/PITR, no filestore copy. The replica mirrors that *shape*; the follow-up
|
||||
card (`t_8bdd3708`) proves the failure mode deliberately rather than hiding it.
|
||||
Two consequences to keep in mind while auditing:
|
||||
### Schedule, retention, location
|
||||
|
||||
1. `pg_dump` of `odoo` + `metabase` reproduces Odoo's database and Metabase's
|
||||
questions/dashboards. It does **not** reproduce `/var/lib/odoo/filestore`.
|
||||
2. A DB-only restore therefore produces an Odoo instance where the attachment
|
||||
list is intact and every download 404s. That is the client's real exposure
|
||||
too, if their cron really copies only the DB.
|
||||
| Item | Value |
|
||||
|---|---|
|
||||
| CronJob | `farrisilk/pg-backup` |
|
||||
| Schedule | `17 3 * * *`, `timeZone: America/Los_Angeles` (nightly) |
|
||||
| Guard rails | `concurrencyPolicy: Forbid`, `startingDeadlineSeconds: 600`, `backoffLimit: 1`, `activeDeadlineSeconds: 1800`, history 3 ok / 3 failed |
|
||||
| Databases | `odoo` **and** `metabase`, one `pg_dump -Fc` each |
|
||||
| Filename | `/backups/<db>-<UTC ts>.dump`, e.g. `odoo-20261122T074011Z.dump` |
|
||||
| Retention | **14 days** (`RETENTION_DAYS=14`, `find /backups -name '*.dump' -mtime +14 -delete`) |
|
||||
| Storage | PVC `backup-data`, 10 Gi, `local-path`, mounted at `/backups` |
|
||||
| Script | ConfigMap `pg-backup-script` (`backup.sh`), no ServiceAccount/RBAC (default SA, token not mounted) |
|
||||
| Credentials | `pg-app` Secret via env (`PGUSER`/`PGPASSWORD`) — never in git or in the manifest |
|
||||
|
||||
Per-run log line (the only evidence a run happened; it lands in the Job pod log):
|
||||
|
||||
```
|
||||
backup: ok db=odoo file=odoo-20261122T074011Z.dump size=2202025B toc_entries=4876 duration=1s
|
||||
backup: ok db=metabase file=metabase-20261122T074011Z.dump size=1274779B toc_entries=2923 duration=0s
|
||||
backup: retention sweep, deleting *.dump older than 14 days
|
||||
backup: run complete rc=0 total=1s dumps_on_disk=2
|
||||
```
|
||||
|
||||
The script fails the Job (`rc=1`) if any `pg_dump` fails **or** if the archive
|
||||
comes back with an empty TOC — a broken backup turns red instead of silently
|
||||
succeeding, which a bare `pg_dump >> log 2>&1` cron does not do.
|
||||
|
||||
**Where the dumps actually are:** `/opt/local-path-provisioner/pvc-8f164f6c-…_farrisilk_backup-data`
|
||||
on **siriussec only**. `local-path` is node-local, so the backup dies with the
|
||||
node. No off-box copy is implemented: the Garage S3 API at
|
||||
`http://10.10.0.1:3900` is reachable from a pod, but it needs a bucket plus
|
||||
credentials that are not part of this namespace, so it was not wired in one
|
||||
pass. That absence is deliberate — it is the same absence in the client's
|
||||
described setup.
|
||||
|
||||
Trigger a run on demand (what the manual proof below did):
|
||||
|
||||
```bash
|
||||
kubectl -n farrisilk create job --from=cronjob/pg-backup pg-backup-manual-1
|
||||
kubectl -n farrisilk logs job/pg-backup-manual-1
|
||||
```
|
||||
|
||||
### Restore — it is TWO steps, and the second one is the one people forget
|
||||
|
||||
**1. Database** (dumps live on the `backup-data` PVC; mount it in a throwaway pod
|
||||
or exec where it is mounted):
|
||||
|
||||
```bash
|
||||
createdb -h pg -U postgres <target_db>
|
||||
pg_restore -h pg -U postgres -d <target_db> /backups/odoo-<ts>.dump
|
||||
psql -h pg -U postgres -d <target_db> -tAc 'select count(*) from res_users'
|
||||
```
|
||||
|
||||
Restoring into the same cluster works without extra flags because the `odoo`
|
||||
role and the schema already exist; into a *different* cluster use
|
||||
`--no-owner --no-privileges` (then re-assign ownership). `-Fc` archives are
|
||||
also readable with `pg_restore --list` and can be inspected without touching a
|
||||
database.
|
||||
|
||||
**2. Filestore** — this backup does **not** contain it. Copy the attachment
|
||||
bytes from the Odoo PVC by hand:
|
||||
|
||||
```bash
|
||||
# from the Odoo pod (uid 100): tar the filestore directory, not the DB
|
||||
kubectl -n farrisilk exec deploy/odoo -- \
|
||||
tar czf - -C /var/lib/odoo filestore | gzip -d | tar xzf - -C <restore-data-dir>
|
||||
```
|
||||
|
||||
The directory name is the **database name**: `/var/lib/odoo/filestore/odoo`.
|
||||
Restoring the dump into `odoo_restore_probe` makes Odoo look in
|
||||
`/var/lib/odoo/filestore/odoo_restore_probe`, which does not exist — renaming or
|
||||
copying the filestore tree to match the restored DB name is a required manual
|
||||
step.
|
||||
|
||||
### Proof from the 2026-11-22 run (numbers, not assertions)
|
||||
|
||||
| Check | Result |
|
||||
|---|---|
|
||||
| Job | `pg-backup-manual-1` — `Complete 1/1`, pod `Completed` |
|
||||
| odoo dump | 2,202,025 B, `pg_restore --list` = **4876** entries |
|
||||
| metabase dump | 1,274,779 B, `pg_restore --list` = **2923** entries |
|
||||
| Restore probe | `createdb odoo_restore_probe` → `pg_restore -d` → **rc 0** |
|
||||
| Row counts | live `res_users`=**5** vs restored=**5**; live `ir_attachment`=**22** vs restored=**22** |
|
||||
| Cleanup | `odoo_restore_probe` dropped; probe pods deleted |
|
||||
| Retention sweep | 30-day-old `*.dump` deleted by the exact `find`, fresh file kept |
|
||||
|
||||
### The gap this method carries — demonstrated, not asserted
|
||||
|
||||
After the restore above, the database is complete and healthy. The attachments
|
||||
are not:
|
||||
|
||||
- Restored DB references **22** `ir_attachment` rows, **21** of them with a
|
||||
`store_fname` (file bytes).
|
||||
- The backup volume holds exactly **2** files: the two `.dump` archives.
|
||||
**0 of the 21 referenced files** exist anywhere under `/backups` (checked
|
||||
every `store_fname` against the volume).
|
||||
- `pg_restore --list` contains **0** filestore/blob entries — the dump carries
|
||||
rows, not bytes.
|
||||
- The live filestore is **23 files / 732 KiB** under
|
||||
`/var/lib/odoo/filestore/odoo`; none of it is in the backup.
|
||||
- End-to-end: the same attachment id fetched from the **live** instance and from
|
||||
a throwaway Odoo bound to the **restored** database:
|
||||
|
||||
```
|
||||
live /web/content/15 -> 200 25613B (res.partner 2, image_1024)
|
||||
restored DB /web/content/15 -> 500 265B
|
||||
live /web/content/22 -> 200 447998B (web assets bundle)
|
||||
restored DB /web/content/22 -> 500 265B
|
||||
```
|
||||
|
||||
and the restored instance's log names the missing file exactly:
|
||||
|
||||
```
|
||||
FileNotFoundError: [Errno 2] No such file or directory:
|
||||
'/var/lib/odoo/filestore/odoo_restore_probe/a3/a305c7712711bdddb2561500d8fcab0ead92ebd6'
|
||||
```
|
||||
|
||||
**User-visible consequence:** after a DB-only restore the database looks
|
||||
perfectly healthy — users, invoices and records are all there — but every
|
||||
invoice PDF, pricelist, product image and attachment download **404s or 500s**.
|
||||
The client would discover this at the moment they need the backup, not before.
|
||||
|
||||
### RPO / consistency statement
|
||||
|
||||
- Nightly dump, **no WAL archiving, no PITR**: worst-case **RPO is 24 hours** of
|
||||
orders, invoices and attachments. Anything written after 03:17 is gone.
|
||||
- The dump is a single `pg_dump` per database and is **not point-in-time
|
||||
consistent with the filestore**: files written while the dump runs are either
|
||||
present on disk and absent from the DB, or referenced by the DB after the
|
||||
dump snapshot but missing from any earlier filestore tar — even a correct
|
||||
DB+filestore restore has a skew window.
|
||||
- There is no automated restore test, no checksum/encryption, and no alert on a
|
||||
failed cron run beyond the Job's own status. A silent `pg_dump` failure on a
|
||||
cron is invisible until the day it is needed.
|
||||
|
||||
### What the client's stated method does not cover (Week 3 remediation register)
|
||||
|
||||
| # | Not covered | Impact |
|
||||
|---|---|---|
|
||||
| 1 | Filestore / attachment bytes | 22 attachment rows, 0 bytes restorable; all downloads/PDFs/images break after restore |
|
||||
| 2 | WAL archiving / PITR | up to 24 h data loss; no restore to a point before a bad import/delete |
|
||||
| 3 | Off-box copy | dumps sit on the same host as the database; host/disk/ransomware loss takes both |
|
||||
| 4 | Restore testing | untested dumps are hypotheses; no evidence they restore |
|
||||
| 5 | Point-in-time consistency DB↔filestore | skewed restores even when both are copied |
|
||||
| 6 | Failure alerting/verification | a failed cron dump is silent; Job status is the only signal here |
|
||||
| 7 | Encryption at rest / access control on dumps | plain `.dump` files readable by anyone with the volume |
|
||||
| 8 | Retention policy enforcement beyond 14 d | unbounded growth or, if scripts differ, no policy at all |
|
||||
|
||||
Closing these (barman/PITR, object storage, filestore tar+checksum, scheduled
|
||||
restore drills) is an **architectural recommendation for the client**, not a
|
||||
change to this replica — no CNPG/barman is added here on purpose: the replica
|
||||
exists to reproduce the client's exposure.
|
||||
|
||||
## PDF reports
|
||||
|
||||
|
|
|
|||
|
|
@ -6,10 +6,12 @@
|
|||
# "improve" this into a CNPG Cluster: the point is to develop and audit against
|
||||
# the client's actual architecture, not ours.
|
||||
#
|
||||
# Known gap (stated plainly on purpose): there are NO backups of this database.
|
||||
# The client's practice is a cron-driven `pg_dump` of the DB only; that mirrors
|
||||
# into a separate follow-up card for this namespace, and no PITR/barman story
|
||||
# is being invented here.
|
||||
# Backups: none at the database level — no WAL archive, no replica, no PITR.
|
||||
# The client's practice (a cron-driven `pg_dump` of the DB only) is mirrored by
|
||||
# `backup.yaml` in this directory: nightly logical dumps, 14-day retention, on a
|
||||
# node-local PVC, with the filestore deliberately NOT covered. See README.
|
||||
# Do not "improve" this into a CNPG Cluster: the point is to develop and audit
|
||||
# against the client's actual architecture, not ours.
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
|
|
|
|||
Loading…
Reference in a new issue