feat(backup): encrypted nightly backup of the bot service's state (#11) #15
No reviewers
Labels
No labels
ready-for-agent
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bryan/nix-configs!15
Loading…
Reference in a new issue
No description provided.
Delete branch "n11-2-pi-bots-backup"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Part of #11 (N11.2): an encrypted nightly backup of the bot service's state to the NAS, with a failure alert.
What changes
services.pi-bots-backup(new,modules/services/pi-bots-backup.nix,scripts/pi-bots-backup.sh): a user LaunchAgent at 03:30 archives the bot service's state directory (SQLite key stores and journals through the online backup,quick_checked and folded out of WAL; sessions; sync positions) and its secrets directory into one tar, compresses it with zstd and encrypts it withageto the configured public keys on local disk. Only the public key is in the repository; the identity stays on the Studio and is used only to check each archive opens before it is published. Publishing followshermes-nas-backup: live smbfs check,.partial-<stamp>then read-back checksum then rename, retention by stamp name (14). Every step on the share runs undertimeout.pi-bots-backup.promfor node_exporter's textfile collector;PiBotsBackupFailed,PiBotsBackupOverdue(no success for 26 h) andPiBotsBackupMissing(never reported).services.nas-mounts(new,modules/services/nas-mounts.nix,scripts/nas-mount.sh): a user LaunchAgent keeps the backup share mounted (mount_smbfs -N, password from the login keychain,soft,nobrowse), at login, every 5 minutes and on network changes. It never mounts over files or another mount. Studio mounts it at~/NAS/Bryan, and the Hermes backup and the NAS write probe move to that path.modules/services/AGENTS.md, README.Tests
python3 scripts/test_pi_bots_backup.py(42): the backup against stand-in state and shares (encrypted, opens only with its key, nothing readable on the share, WAL contents kept and databases standing alone, sockets/locks left out, symlinks and non-ASCII names kept, a killed run's working directory swept, unmounted/non-SMB/not-its-own-device/read-only/corrupting/hanging shares, retention never following links, locks, metrics), the mount script against a stand-inmount_smbfs, the module's agents and refusals, andpromtool test rulesfor the three alerts.test_nas_storage_health.pyandtest_hermes_nas_backup.pypass;darwin-rebuild build --flake .#studiobuilds.quick_check.Review
A visible read-only Pi reviewer (Opus 5.5, medium) found three should-fixes (a killed run's working directory not swept; a symlink failing the member check; the device-ID guard untested) and eight nits, then one more should-fix after the first correction (non-ASCII names in the member check). All were fixed with tests that fail under mutation, except two nits left by agreement (a torn last line in a live session file, for the restore test; a harmless tar warning on sockets). Approved on
01acd25.