Add notify-backup-failure command
Sends a high-priority ntfy message that the nightly backup failed, naming the newest backup still on disk. It exits 1 if the message can't be delivered and 0 (with a note on stderr) when ntfy isn't configured. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6652a4d795
commit
8a9a3ca56d
4 files changed
+90
No files matched your search
@@ -96,6 +96,15 @@ def backup(path: str, dest: str) -> None:
|
||||
_BACKUP_NAME = re.compile(r"^kernelwatch-(\d{4})-(\d{2})-(\d{2})\.db$")
|
||||
|
||||
|
||||
def latest_backup(directory: str) -> str | None:
|
||||
"""Name of the newest dated backup in directory, or None."""
|
||||
try:
|
||||
names = [n for n in os.listdir(directory) if _BACKUP_NAME.match(n)]
|
||||
except OSError:
|
||||
return None
|
||||
return max(names, default=None)
|
||||
|
||||
|
||||
def rotate_backups(path: str, directory: str, keep_days: int, now: float | None = None) -> str:
|
||||
"""Back the database up to <directory>/kernelwatch-YYYY-MM-DD.db (UTC date),
|
||||
replacing that day's file, then delete dated backups that are keep_days or more
|
||||
|
||||
Reference in new issue
Block a user