From 42a1b41b0134c11905c6f6294eee7b6c1a44a66e Mon Sep 17 00:00:00 2001 From: patrickbeane Date: Thu, 29 Oct 2026 20:37:54 -0400 Subject: [PATCH] Document backups and restore Co-Authored-By: Claude Sonnet 5.5 --- README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/README.md b/README.md index e447408..0035ea2 100644 --- a/README.md +++ b/README.md @@ -438,10 +438,32 @@ sudo kernelwatch list-hosts hosts and when they last reported sudo kernelwatch set-password USER create a user / change password (logs out their sessions) sudo kernelwatch remove-user USER sudo kernelwatch list-users +sudo kernelwatch backup PATH write a consistent copy of the database (safe while running) sudo kernelwatch check-alerts check for stale, recovered, reboot and update alerts now sudo kernelwatch test-alert send a test notification to the configured ntfy topic ``` +## Backups + +Everything kernelwatch knows lives in one SQLite file, `/var/lib/kernelwatch/kernelwatch.db`: +host tokens (hashed), dashboard logins and report history. Without it you'd +re-register every host and reinstall its token. Don't copy the file while the +server runs, since recent writes can sit in its `-wal` sidecar. Use: + +```sh +sudo kernelwatch backup /var/lib/kernelwatch/backups/kernelwatch.db +``` + +This uses SQLite's online backup, so it's safe while hosts are reporting. It +replaces any existing file at that path and writes it mode 0600. It refuses to +overwrite the live database. The command runs as the `kernelwatch` user, so the +destination directory has to be writable by it (create one with +`sudo install -d -o kernelwatch -g kernelwatch -m 0700 /var/lib/kernelwatch/backups`), +then copy the result off the machine with your usual backup tool. + +To restore, stop the service, put the file at `db_path` owned by `kernelwatch` +(mode 0600), and start it again. The stale-alert state restores with it. + ## Security notes - **Host identity comes from the token, not the payload.** A host can only