Add alert tools, mutes, short status, and backup summary
This commit is contained in:
@@ -37,6 +37,16 @@ def _sudo_cmd(cmd: list[str]) -> list[str]:
|
||||
return ["sudo", "-E"] + cmd
|
||||
|
||||
|
||||
def _format_backup_result(rc: int, out: str) -> str:
|
||||
log_hint = "log: /var/log/backup-auto.log"
|
||||
header = "✅ Backup finished" if rc == 0 else "❌ Backup failed"
|
||||
lines = out.strip().splitlines()
|
||||
body = "\n".join(lines[:20])
|
||||
if len(lines) > 20:
|
||||
body += f"\n… trimmed {len(lines) - 20} lines"
|
||||
return f"{header} (rc={rc})\n{log_hint}\n\n{body}" if body else f"{header} (rc={rc})\n{log_hint}"
|
||||
|
||||
|
||||
def _load_json(raw: str, label: str) -> tuple[bool, object | None, str]:
|
||||
if not raw or not raw.strip():
|
||||
return False, None, f"? {label} returned empty output"
|
||||
@@ -215,7 +225,7 @@ async def cmd_backup_now(msg: Message):
|
||||
use_restic_env=True,
|
||||
timeout=6 * 3600,
|
||||
)
|
||||
await msg.answer(("✅ OK\n" if rc == 0 else "❌ FAIL\n") + out, reply_markup=backup_kb)
|
||||
await msg.answer(_format_backup_result(rc, out), reply_markup=backup_kb)
|
||||
finally:
|
||||
release_lock("backup")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user