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
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:
1 parent
3624f0e5d9
commit
4a9bc77a08
10 files changed
+281
-3
No files matched your search
@@ -30,6 +30,12 @@ class Config:
|
||||
# Package lists older than this make "no updates" untrustworthy.
|
||||
apt_stale_after_hours: float = 48.0
|
||||
report_retention_days: int = 30
|
||||
|
||||
# Where `scheduled-backup` (kernelwatch-backup.timer) writes dated copies of the
|
||||
# database, and how many days of them it keeps; 0 keeps them all. It must stay
|
||||
# under /var/lib/kernelwatch unless the backup unit is given more write access.
|
||||
backup_dir: str = "/var/lib/kernelwatch/backups"
|
||||
backup_keep_days: int = 7
|
||||
# A host's reports closer together than this are refused with 429; 0 disables.
|
||||
report_min_interval_seconds: int = 30
|
||||
|
||||
@@ -78,6 +84,10 @@ def load(path: str | None = None) -> Config:
|
||||
raise SystemExit(f"{path}: ntfy_timeout_seconds must be positive and finite")
|
||||
if cfg.report_min_interval_seconds < 0:
|
||||
raise SystemExit(f"{path}: report_min_interval_seconds must be zero or positive")
|
||||
if cfg.backup_keep_days < 0:
|
||||
raise SystemExit(f"{path}: backup_keep_days must be zero or positive")
|
||||
if not cfg.backup_dir.startswith("/") or any(ord(c) < 32 or ord(c) == 127 for c in cfg.backup_dir):
|
||||
raise SystemExit(f"{path}: backup_dir must be an absolute path")
|
||||
if not math.isfinite(cfg.status_alert_after_hours) or cfg.status_alert_after_hours < 0:
|
||||
raise SystemExit(f"{path}: status_alert_after_hours must be zero or positive and finite")
|
||||
if any(ord(c) < 32 or ord(c) == 127 for c in cfg.ntfy_url + cfg.ntfy_token):
|
||||
|
||||
Reference in new issue
Block a user