feat(backup): add ops-db backup commands, flow, and systemd timer
Adds pg_dump_ops_db, list_ops_backups, and cleanup_ops_backups to the agent command whitelist. Includes a backup_ops_db flow YAML (dump + 30-day retention), and a systemd service/timer for daily automated backups at 02:00. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
aa1fd41bec
commit
4dd0490afc
4 changed files with 85 additions and 0 deletions
|
|
@ -203,3 +203,36 @@ commands:
|
|||
- -c
|
||||
- "code=$(curl -s -o /dev/null -w '%{http_code}' --max-time 15 https://thuis.jp-visser.nl/api/products); echo \"HTTP $code\"; [ \"$code\" = \"200\" ] || [ \"$code\" = \"401\" ]"
|
||||
description: "Smoke test: /api/products must return 200 or 401"
|
||||
|
||||
# ── Ops-dashboard database backup ────────────────────────────────────────
|
||||
|
||||
pg_dump_ops_db:
|
||||
cmd:
|
||||
- sh
|
||||
- -c
|
||||
- |
|
||||
mkdir -p /srv/ops/backups
|
||||
FNAME="/srv/ops/backups/ops_db_$(date +%Y%m%d_%H%M).dump"
|
||||
docker exec postgres pg_dump -Fc ops_dashboard > "$FNAME"
|
||||
echo "Backup written: $FNAME"
|
||||
ls -lh "$FNAME"
|
||||
description: "Dump ops_dashboard DB via docker exec postgres to /srv/ops/backups/"
|
||||
|
||||
list_ops_backups:
|
||||
cmd:
|
||||
- sh
|
||||
- -c
|
||||
- "find /srv/ops/backups -maxdepth 1 -name '*.dump' -printf '%f\\t%s\\n' 2>/dev/null | sort -r || true"
|
||||
description: "List ops_dashboard backup files (filename TAB size_bytes, newest-first)"
|
||||
|
||||
cleanup_ops_backups:
|
||||
cmd:
|
||||
- find
|
||||
- /srv/ops/backups
|
||||
- -name
|
||||
- "*.dump"
|
||||
- -mtime
|
||||
- "+30"
|
||||
- -delete
|
||||
- -print
|
||||
description: "Delete ops_dashboard backup files older than 30 days"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue