Files
vh 6e203dcb99 fix(restic): stop publishing rest-server passwords in systemd units
resticprofile schedule copies env-file values into the generated units, which
are 0644, so RESTIC_REPOSITORY (the rest-server basic-auth password included)
was readable by every local user on every restic host.

New playbooks/restic-repository-file.yaml:
- derives /etc/restic/repository (root 0400) from restic.env;
- uploads the profile switched to repository-file, but only when the live
  profile's sha matches the repo copy it was edited from (drift guard);
- checks the repository is reachable through the new profile (cat config);
- regenerates the units and verifies they exist and contain no rest:http.

Applied to ana-docker, fv-ml1 (configs/restic/ana-ml2), esh-docker-vm,
esh-vm-db, irv-ml1, nh3-dev and nh3-docker. An independent check across all
eight restic hosts (these seven plus esh-ml1) found 0 leaking units. nh3-docker's
scheduled unit ran a real backup afterwards (snapshot a29b889d). Each host's
URL and passphrase are vaulted as <host>/etc/restic/{repository,password}.

restic.env is kept (root 0600) because the per-host READMEs and the freshness
probe source it. A rotation must update the vault, restic.env and repository.

vm-esh-nas has no infra-ops account. Its in-place migration script is staged
for Prime to run with sudo, and its repo profile is pre-edited to match.

Also mirrors augaman-dev's 401df2d (compose header only). The config hash on
esh-ml1 is unchanged.
2026-09-27 01:51:05 -07:00

92 lines
2.9 KiB
YAML

# resticprofile config for esh-vm-db.
#
# Two-database host (Postgres 15 on :5432, MongoDB on :27017). Small
# VM on an ESH hypervisor; backed up at VM-image level by PBS-ANA via
# its hypervisor. This restic profile captures:
#
# 1. Host config (/etc, /root) — fast config recovery without
# waiting for VM-image restore
# 2. Per-DB dumps via pre-backup hook — pg_dumpall + mongodump,
# written to /var/lib/restic/stage/ and included in the restic
# snapshot. Gives us DB-level restore granularity alongside the
# VM-image restore from PBS.
#
# What's DELIBERATELY NOT in source:
# - /var/lib/postgresql — raw live PGDATA. Inconsistent if captured
# while postgres is running; pg_dumpall above covers this.
# - /var/lib/mongodb — same reasoning; mongodump covers it.
#
# Writes cross-site to rest-server-ana (10.250.50.70:8000). No local
# NH3-style rest-server on the ESH side; esh-docker-vm and vm-esh-nas
# also use rest-server-ana, so this follows fleet pattern.
version: "1"
global:
priority: low
ionice: true
ionice-class: 2
ionice-level: 7
min-memory: 100
default:
repository-file: /etc/restic/repository # URL incl. rest-server creds (root 0400).
# NOT env-file: `resticprofile schedule` copies env-file values into the
# world-readable systemd units (docs/runbooks/backups.md, Known gaps).
env:
RESTIC_PASSWORD_FILE: /etc/restic/password
initialize: false
lock: /var/lock/restic-esh-vm-db.lock
backup:
verbose: 1
run-before:
- /etc/restic/pre-backup.sh
run-after:
- date +%s > /var/lib/restic/last-success
source:
- /etc # host config
- /root # root's scripts, ssh keys, shell history
- /home # user home dirs
- /var/lib/restic/stage # pg_dumpall + mongodump outputs from pre-backup
exclude:
# Raw DB data is captured via pre-backup dumps, not volume-level
- /var/lib/postgresql
- /var/lib/mongodb
# NFS mount from esh-nas (backup target for other stacks — not ours to mirror)
- /mnt/backup
# Ephemeral / regenerable
- "**/*.log"
- "**/*.log.*"
- "**/*.pid"
- /root/.cache
- /root/.local/share/Trash
- /root/.npm
- /root/.python_history
- /home/*/.cache
- /home/*/.local/share/Trash
- /home/*/.npm
tag:
- host:esh-vm-db
- site:esh
- fleet:home-lab
schedule: "*-*-* 01:00:00"
schedule-permission: system
schedule-log: /var/log/restic-backup.log
forget:
keep-daily: 7
keep-weekly: 4
keep-monthly: 12
keep-yearly: 3
tag:
- host:esh-vm-db
# Schedule removed: forget against --append-only rest-server always
# fails (delete ops blocked). Run manually during prune ceremony.
check:
read-data-subset: 10%
schedule: "Sun *-*-* 05:00:00"
schedule-permission: system
schedule-log: /var/log/restic-check.log