diff --git a/handlers/backup.py b/handlers/backup.py index ebd3193..e9324bb 100644 --- a/handlers/backup.py +++ b/handlers/backup.py @@ -7,7 +7,7 @@ from app import dp from auth import is_admin_msg from keyboards import backup_kb from lock_utils import acquire_lock, release_lock -from services.backup import backup_badge, last_backup, restore_help +from services.backup import backup_badge, restore_help from services.runner import run_cmd @@ -124,15 +124,6 @@ async def cmd_backup_now(msg: Message): asyncio.create_task(worker()) -async def cmd_last_backup(msg: Message): - try: - text = await asyncio.to_thread(last_backup) - except Exception as e: - await msg.answer(f"❌ Last backup failed: {type(e).__name__}: {e}", reply_markup=backup_kb) - return - await msg.answer(text, reply_markup=backup_kb) - - async def cmd_last_snapshot(msg: Message): await msg.answer("⏳ Loading last snapshot…", reply_markup=backup_kb) @@ -191,12 +182,6 @@ async def rs(msg: Message): await cmd_repo_stats(msg) -@dp.message(F.text == "📦 Last backup") -async def lb(msg: Message): - if is_admin_msg(msg): - await cmd_last_backup(msg) - - @dp.message(F.text == "📦 Last snapshot") async def ls(msg: Message): if is_admin_msg(msg): diff --git a/keyboards.py b/keyboards.py index 32a4cfa..cb98c14 100644 --- a/keyboards.py +++ b/keyboards.py @@ -27,13 +27,9 @@ docker_kb = ReplyKeyboardMarkup( backup_kb = ReplyKeyboardMarkup( keyboard=[ - [KeyboardButton(text="📦 Status")], - [KeyboardButton(text="📦 Last backup")], - [KeyboardButton(text="📦 Last snapshot")], - [KeyboardButton(text="📊 Repo stats")], - [KeyboardButton(text="▶️ Run backup")], - [KeyboardButton(text="🧯 Restore help")], - [KeyboardButton(text="⬅️ Назад")], + [KeyboardButton(text="📦 Status"), KeyboardButton(text="📦 Last snapshot")], + [KeyboardButton(text="📊 Repo stats"), KeyboardButton(text="🧯 Restore help")], + [KeyboardButton(text="▶️ Run backup"), KeyboardButton(text="⬅️ Назад")], ], resize_keyboard=True, ) diff --git a/services/backup.py b/services/backup.py index da92723..170e912 100644 --- a/services/backup.py +++ b/services/backup.py @@ -1,7 +1,6 @@ from datetime import datetime, timezone from typing import Optional import json -import subprocess from services.runner import run_cmd @@ -33,23 +32,6 @@ async def get_last_snapshot() -> Optional[dict]: return snaps[0] -def last_backup() -> str: - 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() -> str: return ( "🧯 Restore help\n\n"