apps(backup): cover the remaining stateful gaps off-host

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.
This commit is contained in:
Lance Walters 2026-11-19 17:14:36 -05:00
commit c1fe485469
12 changed files with 713 additions and 18 deletions

View file

@ -0,0 +1,46 @@
---
# Lets the nightly `forgejo/cluster-backup` CronJob take a `pg_dump` of the
# plain (non-CNPG) Postgres Deployment `osint/osint-db` through the exec API.
#
# `osint-db` is a stock `postgres` Deployment, so there is no Cluster object and
# no `status.currentPrimary` to look up; the dump is taken inside the pod over
# the local socket and uses the pod's own `POSTGRES_USER`/`POSTGRES_DB`, so no
# password is copied into `forgejo`, git or the Job.
#
# Least privilege: the ServiceAccount may run one command inside this
# namespace's pods — nothing else.
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: cluster-backup
namespace: osint
labels:
app: cluster-backup
rules:
- apiGroups: [""]
resources: ["pods"]
verbs: ["get", "list"]
- apiGroups: [""]
resources: ["pods/exec"]
verbs: ["create"]
# `kubectl exec deploy/osint-db` resolves the Deployment's ReplicaSet/pod, so
# it needs read access to the deployment itself.
- apiGroups: ["apps"]
resources: ["deployments"]
verbs: ["get"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: cluster-backup
namespace: osint
labels:
app: cluster-backup
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: cluster-backup
subjects:
- kind: ServiceAccount
name: cluster-backup
namespace: forgejo

View file

@ -18,3 +18,6 @@ resources:
- news-scraper-deployment.yaml
- news-summarizer-deployment.yaml
- httproute.yaml
# exec-only RBAC so forgejo/cluster-backup can pg_dump this namespace's plain
# Postgres Deployment (osint-db) — not a CNPG cluster, so it needs its own path.
- backup-exec-rbac.yaml