Initial version of Telegram admin bot
This commit is contained in:
27
backups.py
Normal file
27
backups.py
Normal 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"
|
||||
)
|
||||
Reference in New Issue
Block a user