Initial version of Telegram admin bot

This commit is contained in:
root
2026-02-07 21:34:24 +03:00
commit 492e3bd3cf
9 changed files with 1027 additions and 0 deletions

27
backups.py Normal file
View File

@@ -0,0 +1,27 @@
import json
from datetime import datetime
from pathlib import Path
def last_backup():
import subprocess
out = subprocess.check_output(
["restic", "snapshots", "--json"],
env=None
).decode()
snaps = json.loads(out)
snaps.sort(key=lambda s: s["time"], reverse=True)
s = snaps[0]
t = datetime.fromisoformat(s["time"].replace("Z", ""))
return (
"📦 Last backup\n\n"
f"🕒 {t:%Y-%m-%d %H:%M}\n"
f"🧊 ID: {s['short_id']}\n"
f"📁 Paths: {len(s['paths'])}"
)
def restore_help():
return (
"🧯 Restore help\n\n"
"Example:\n"
"restic restore <snapshot_id> --target /restore"
)