Add weekly report, multi-admin, docker health cmd, backup tail, openwrt filters
This commit is contained in:
@@ -38,13 +38,29 @@ def _sudo_cmd(cmd: list[str]) -> list[str]:
|
||||
|
||||
|
||||
def _format_backup_result(rc: int, out: str) -> str:
|
||||
log_hint = "log: /var/log/backup-auto.log"
|
||||
log_path = "/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}"
|
||||
extra = ""
|
||||
if rc != 0 and os.path.exists(log_path):
|
||||
try:
|
||||
tail = ""
|
||||
with open(log_path, "r", encoding="utf-8", errors="replace") as f:
|
||||
tail_lines = f.readlines()[-40:]
|
||||
tail = "".join(tail_lines).strip()
|
||||
if tail:
|
||||
extra = "\n\nLog tail:\n" + tail
|
||||
except Exception:
|
||||
pass
|
||||
base = f"{header} (rc={rc})\nlog: {log_path}"
|
||||
if body:
|
||||
base += "\n\n" + body
|
||||
if extra:
|
||||
base += extra
|
||||
return base
|
||||
|
||||
|
||||
def _load_json(raw: str, label: str) -> tuple[bool, object | None, str]:
|
||||
@@ -231,6 +247,11 @@ async def cmd_backup_now(msg: Message):
|
||||
|
||||
pos = await enqueue("backup", job)
|
||||
await msg.answer(f"🕓 Backup queued (#{pos})", reply_markup=backup_kb)
|
||||
try:
|
||||
from services.incidents import log_incident
|
||||
log_incident(cfg, f"backup_queued by {msg.from_user.id}")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
async def cmd_last_snapshot(msg: Message):
|
||||
|
||||
Reference in New Issue
Block a user