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 --target /restore" )