Back up the database nightly with a timer
CI / tests (Python 3.10) (pull_request) Successful in 23s
CI / tests (Python 3.11) (pull_request) Successful in 25s
CI / tests (Python 3.12) (pull_request) Successful in 24s
CI / tests (Python 3.13) (pull_request) Successful in 24s
CI / lint (pull_request) Successful in 3s

kernelwatch scheduled-backup writes kernelwatch-YYYY-MM-DD.db into backup_dir
and prunes dated copies backup_keep_days or older, only after the new backup
succeeded and only files with exactly that name. kernelwatch-backup.timer runs
it at about 03:30 as the unprivileged service user with no network, and
server/install.sh enables it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
patrickandClaude Sonnet 5.5 committed 2026-10-30 10:23:45 -04:00
1 parent 3624f0e5d9
commit 4a9bc77a08
10 files changed
+281 -3

No files matched your search

+13 -1
View File
@@ -306,7 +306,7 @@ class ServerInstallTest(InstallCase):
self.assertEqual(self.systemctl(), [
"daemon-reload", "enable kernelwatch.service", "restart kernelwatch.service",
"enable --now kernelwatch-alerts.timer"])
"enable --now kernelwatch-alerts.timer", "enable --now kernelwatch-backup.timer"])
self.assertIn("listen_host = \"127.0.0.1\"", proc.stdout)
self.assertIn("set-password admin", proc.stdout)
@@ -317,6 +317,18 @@ class ServerInstallTest(InstallCase):
for unit in units:
self.assertEqual(mode(self.path("etc/systemd/system", unit)), 0o644)
def test_unit_commands_exist_in_the_cli(self):
"""Every `kernelwatch-server <command>` a unit runs must be a real subcommand."""
help_text = subprocess.run(["python3", "-I", os.path.join(SERVER_DIR, "kernelwatch-server"), "--help"],
capture_output=True, text=True, timeout=30).stdout
commands = set()
for unit in os.listdir(SERVER_DIR):
if unit.endswith(".service"):
commands.update(re.findall(r"kernelwatch-server (\S+)$", read(os.path.join(SERVER_DIR, unit)), re.M))
self.assertTrue(commands)
for command in commands:
self.assertRegex(help_text, rf"\b{re.escape(command)}\b")
def test_existing_user_is_not_recreated(self):
self.install(KW_ID_RC="0")
self.assertFalse([c for c in self.calls() if c.startswith("useradd")])