apps(backup): cover the remaining stateful gaps — grafana sqlite, osint pgdata, leadgen PVC, Pi WireGuard config #18

Merged
sirius merged 1 commit from feat/t_2b6639de-backup-gaps into master 2026-11-19 22:18:40 +00:00
Owner

What

Closes the stateful gaps left by #17 (docs/cluster-overview.md §8.1). Everything still streams to the Linode over the WireGuard mesh ([email protected]:/root/cluster-backup, Pi artifacts to [email protected]:/root/pihost-backup) — nothing is staged on the 83 %-full T480, nothing targets the Linode public IP.

Gap Artifact Where Retention
Grafana sqlite (55 MiB PVC) grafana/grafana-<stamp>.db monitoring/grafana-backup CronJob 0 3 * * * 14
osint/osint-pgdata (plain Postgres Deployment) db/osint-osint-db-<stamp>.dump PG_TARGETS loop in forgejo/cluster-backup 14
sirius-growth/sgs-leadgen-data (4.9 MiB) leadgen-data/<stamp>/ + latest sirius-growth/leadgen-backup CronJob 7 3 * * * 7
Pi /etc/wireguard + wgportal sqlite wireguard/wireguard-<stamp>.tar.gz infrastructure/wireguard/backup/ systemd timer 14

Design notes

  • Grafana is -distroless — no shell, no tar, so kubectl exec cannot produce a dump. The CronJob mounts the PVC read-write on siriussec and copies with the sqlite backup API (a cp of a live db can capture a torn page), runs PRAGMA integrity_check on the copy, and fails the Job if it is not ok.
  • osint-db is not CNPG, so it gets its own PG_TARGETS path: pg_dump -Fc runs inside the pod and reads its own POSTGRES_USER/POSTGRES_DB over the local socket — no DB password in git, in the Job, or copied across namespaces. Exec-only Role/RoleBinding in apps/base/osint/.
  • Every tree has its own retention (7–14), so adding the 4th artifact cannot crowd the Linode's 48 GiB free.

Evidence (hand-fired runs, real output)

  • monitoring/grafana-backup-manual-2: integrity_check=ok dashboard=0 versions=0 user=1 alert_rule=0 → shipped 2,916,352 bytes sha256 4893a879…935edd; Linode grafana/grafana-20261119T220934Z.db. Read back from the Linode and opened with sqlite: integrity ok, 92 tables, user(admin), 2 data sources.
  • cluster-backup-manual-5: db/osint-osint-db-20261119T220934Z.dump 37,424,476 bytes sha256 2348e954…, plus forgejo-data snapshot and both CNPG dumps unchanged (RESULT=success stamp=20261119T220934Z). Restored from the Linode artifact into a scratch db on the same image (TimescaleDB pre_restore/post_restore required — documented in §8.2): 27/27 public tables, cameras 24120=24120, articles 19653=19653.
  • sirius-growth/leadgen-backup-manual-2: first run 5,020,406 bytes, second run 398 bytes sent, speedup 12039 (link-dest working); 4.9M on the Linode at leadgen-data/latest.
  • Pi wireguard-backup.service: integrity_check=ok peers=3, 8,558 bytes sha256 a28cc4df… → /root/pihost-backup/wireguard/wireguard-20261119T221145Z.tar.gz mode 0600. Read back: tarball lists wg0.conf, wg-remote.conf, their .bak history and wgportal-sqlite.db (integrity ok, 3 peers, 3 addresses); restored wg0.conf sha256 is byte-identical to the live Pi file.

Honest notes

  • Grafana's dashboard/alert_rule tables are empty and that is correct: dashboards, datasources and alert rules are provisioned from git (monitoring/controllers/home/). The db holds users/orgs/prefs/annotations/API keys.
  • The osint dump is only restorable with timescaledb_pre_restore() before and timescaledb_post_restore() after pg_restore — a naive restore drops one hypertable's data. §8.2 now says so.
  • Accepted gaps, with reasons, are in §8.1: Prometheus TSDB, osint-camera-snapshots (4 K of throwaway frames), runner PVCs.
  • The Pi units are host units, not Flux-managed; install steps are in infrastructure/wireguard/backup/README.md. Already installed and enabled on the Pi.
  • The three CronJobs and the osint Role are applied live (hand-applied from this branch) so the runs above are real; they are not in the Flux inventory until this merges.
## What Closes the stateful gaps left by #17 (`docs/cluster-overview.md` §8.1). Everything still streams to the Linode over the WireGuard mesh (`[email protected]:/root/cluster-backup`, Pi artifacts to `[email protected]:/root/pihost-backup`) — nothing is staged on the 83 %-full T480, nothing targets the Linode public IP. | Gap | Artifact | Where | Retention | |---|---|---|---| | Grafana sqlite (55 MiB PVC) | `grafana/grafana-<stamp>.db` | `monitoring/grafana-backup` CronJob `0 3 * * *` | 14 | | `osint/osint-pgdata` (plain Postgres Deployment) | `db/osint-osint-db-<stamp>.dump` | `PG_TARGETS` loop in `forgejo/cluster-backup` | 14 | | `sirius-growth/sgs-leadgen-data` (4.9 MiB) | `leadgen-data/<stamp>/` + `latest` | `sirius-growth/leadgen-backup` CronJob `7 3 * * *` | 7 | | Pi `/etc/wireguard` + wgportal sqlite | `wireguard/wireguard-<stamp>.tar.gz` | `infrastructure/wireguard/backup/` systemd timer | 14 | ## Design notes - **Grafana is `-distroless`** — no shell, no `tar`, so `kubectl exec` cannot produce a dump. The CronJob mounts the PVC read-write on siriussec and copies with the **sqlite backup API** (a `cp` of a live db can capture a torn page), runs `PRAGMA integrity_check` on the copy, and fails the Job if it is not `ok`. - **osint-db is not CNPG**, so it gets its own `PG_TARGETS` path: `pg_dump -Fc` runs inside the pod and reads its own `POSTGRES_USER`/`POSTGRES_DB` over the local socket — no DB password in git, in the Job, or copied across namespaces. Exec-only Role/RoleBinding in `apps/base/osint/`. - Every tree has its own retention (7–14), so adding the 4th artifact cannot crowd the Linode's 48 GiB free. ## Evidence (hand-fired runs, real output) - `monitoring/grafana-backup-manual-2`: `integrity_check=ok dashboard=0 versions=0 user=1 alert_rule=0` → shipped 2,916,352 bytes sha256 `4893a879…935edd`; Linode `grafana/grafana-20261119T220934Z.db`. **Read back** from the Linode and opened with sqlite: `integrity ok`, 92 tables, `user(admin)`, 2 data sources. - `cluster-backup-manual-5`: `db/osint-osint-db-20261119T220934Z.dump` 37,424,476 bytes sha256 `2348e954…`, plus forgejo-data snapshot and both CNPG dumps unchanged (`RESULT=success stamp=20261119T220934Z`). **Restored** from the Linode artifact into a scratch db on the same image (TimescaleDB `pre_restore`/`post_restore` required — documented in §8.2): 27/27 public tables, `cameras 24120=24120`, `articles 19653=19653`. - `sirius-growth/leadgen-backup-manual-2`: first run 5,020,406 bytes, second run **398 bytes sent, speedup 12039** (link-dest working); `4.9M` on the Linode at `leadgen-data/latest`. - Pi `wireguard-backup.service`: `integrity_check=ok peers=3`, 8,558 bytes sha256 `a28cc4df…` → `/root/pihost-backup/wireguard/wireguard-20261119T221145Z.tar.gz` mode 0600. Read back: tarball lists `wg0.conf`, `wg-remote.conf`, their `.bak` history and `wgportal-sqlite.db` (integrity ok, 3 peers, 3 addresses); restored `wg0.conf` sha256 is **byte-identical** to the live Pi file. ## Honest notes - Grafana's `dashboard`/`alert_rule` tables are **empty and that is correct**: dashboards, datasources and alert rules are provisioned from git (`monitoring/controllers/home/`). The db holds users/orgs/prefs/annotations/API keys. - The osint dump is only restorable with `timescaledb_pre_restore()` before and `timescaledb_post_restore()` after `pg_restore` — a naive restore drops one hypertable's data. §8.2 now says so. - Accepted gaps, with reasons, are in §8.1: Prometheus TSDB, `osint-camera-snapshots` (4 K of throwaway frames), runner PVCs. - The Pi units are host units, not Flux-managed; install steps are in `infrastructure/wireguard/backup/README.md`. Already installed and enabled on the Pi. - The three CronJobs and the osint Role are applied live (hand-applied from this branch) so the runs above are real; they are not in the Flux inventory until this merges.
Four pieces of state were still only on the machine they run on. All four now
land on the Linode over the WireGuard mesh, in the same /root/cluster-backup
tree (or /root/pihost-backup for the Pi) with the same manifest/sha256 habit:

* monitoring/kube-prometheus-stack-grafana — new CronJob `monitoring/grafana-backup`.
  The image is -distroless (no shell), so this mounts the PVC read-write and
  takes a consistent copy with the sqlite backup API (PRAGMA integrity_check on
  the copy), then streams it: grafana/grafana-<stamp>.db, keep 14.
* osint/osint-db — plain Postgres Deployment, so neither the CNPG primary lookup
  nor CNPG_TARGETS reaches it. `forgejo/cluster-backup` gains a PG_TARGETS loop
  that pg_dump -Fc's inside the pod using its own POSTGRES_USER/POSTGRES_DB
  (exec-only RBAC in apps/base/osint/), sha256 checked on both sides.
* sirius-growth/sgs-leadgen-data — new CronJob `sirius-growth/leadgen-backup`,
  link-dest snapshot mirror, keep 7.
* Pi /etc/wireguard + wgportal sqlite — infrastructure/wireguard/backup/,
  nightly systemd timer -> [email protected]:/root/pihost-backup, keep 14.

Each tree carries its own retention, so adding artifacts cannot crowd the
Linode. Docs §8/§8.1/§8.2 record coverage, the accepted gaps (Prometheus TSDB,
camera frames, runner scratch) and the restore procedure — including the
TimescaleDB pre/post-restore calls osint needs.
sirius merged commit 95d807852c into master 2026-11-19 22:18:40 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
sirius/homek8s!18
No description provided.