Add kernelwatch backup command #11

Merged
patrick merged 2 commits from feat/backup-command into main 2026-10-30 00:44:01 +00:00
Owner

Summary

Adds kernelwatch backup PATH, which writes a consistent copy of the SQLite
database. The database holds host token hashes, dashboard logins and report
history, and until now the README had no backup guidance. Copying the file
while the server runs can miss writes still in the -wal sidecar.

  • Uses SQLite's online backup API, so it's safe while hosts are reporting.
  • Builds the copy at a 0600 temp file beside PATH, then renames it into place,
    so a failure never leaves a partial backup. An existing file at PATH is
    replaced.
  • Refuses to write over the live database.
  • Exits 1 with backup failed: ... on errors such as a missing directory.

The command runs as the kernelwatch user via the wrapper, so PATH must be
writable by that user. The README documents a backups directory, restore steps,
and copying the result off-box.

No schema change, no config change, no agent change.

Testing

make test: 108 tests pass (4 new). They cover data and token lookup in the
copy including WAL-resident writes, integrity_check, 0600 mode, replacing an
existing file, refusing the live DB, and no leftover temp files after a failure.

🤖 Generated with Claude Code

## Summary Adds `kernelwatch backup PATH`, which writes a consistent copy of the SQLite database. The database holds host token hashes, dashboard logins and report history, and until now the README had no backup guidance. Copying the file while the server runs can miss writes still in the -wal sidecar. - Uses SQLite's online backup API, so it's safe while hosts are reporting. - Builds the copy at a 0600 temp file beside PATH, then renames it into place, so a failure never leaves a partial backup. An existing file at PATH is replaced. - Refuses to write over the live database. - Exits 1 with `backup failed: ...` on errors such as a missing directory. The command runs as the `kernelwatch` user via the wrapper, so PATH must be writable by that user. The README documents a backups directory, restore steps, and copying the result off-box. No schema change, no config change, no agent change. ## Testing `make test`: 108 tests pass (4 new). They cover data and token lookup in the copy including WAL-resident writes, integrity_check, 0600 mode, replacing an existing file, refusing the live DB, and no leftover temp files after a failure. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
patrick added 2 commits 2026-10-30 00:41:45 +00:00
Uses SQLite's online backup API, so it is consistent while the server is
writing in WAL mode. Writes mode 0600 via a temp file and rename, and
refuses to overwrite the live database.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Document backups and restore
CI / tests (Python 3.10) (pull_request) Successful in 19s
CI / tests (Python 3.11) (pull_request) Successful in 18s
CI / tests (Python 3.12) (pull_request) Successful in 18s
CI / tests (Python 3.13) (pull_request) Successful in 18s
CI / lint (pull_request) Successful in 3s
42a1b41b01
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
patrick merged commit 8cb7ef5e8b into main 2026-10-30 00:44:01 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: patrick/kernel-automation#11