Add local backup retention: keep-local toggle, download, delete-local
CI / Frontend build (push) Successful in 12s
CI / Script syntax (push) Successful in 3s
CI / Backend tests (push) Successful in 17s

Lets operators opt into keeping the local archive after upload (global
keep_local_backups setting), pull a remote archive back down into the
Proxmox dump directory for manual restore, and drop a locally-retained
copy without touching the remote object. Consolidates deletion so
retention, job-cascade delete, manual delete, and crash-recovery resume
all clean up local copies alongside remote ones.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Codex
2026-07-15 12:58:52 +02:00
parent 1288ba731d
commit 508decffe3
9 changed files with 404 additions and 35 deletions
+25
View File
@@ -15,6 +15,8 @@ from .backup_service import (
dashboard,
delete_backup_manually,
delete_job_with_backups,
delete_local_copy,
download_backup_locally,
get_backup,
list_backups,
process_backup,
@@ -40,6 +42,7 @@ class SettingsPayload(BaseModel):
default_retention_value: int = 30
max_concurrent_backups: int = 1
timezone: str = "UTC"
keep_local_backups: bool = False
setup_complete: bool = False
@@ -252,6 +255,28 @@ async def delete_backup(backup_id: str):
raise HTTPException(409, str(exc)) from exc
@app.post("/api/backups/{backup_id}/download")
async def download_backup(backup_id: str):
try:
return await download_backup_locally(backup_id)
except KeyError as exc:
raise HTTPException(404, str(exc)) from exc
except RuntimeError as exc:
raise HTTPException(409, str(exc)) from exc
except Exception as exc:
raise HTTPException(502, f"Download failed: {exc}") from exc
@app.delete("/api/backups/{backup_id}/local")
async def delete_backup_local_copy(backup_id: str):
try:
return await delete_local_copy(backup_id)
except KeyError as exc:
raise HTTPException(404, str(exc)) from exc
except RuntimeError as exc:
raise HTTPException(409, str(exc)) from exc
if (STATIC_DIR / "assets").exists():
app.mount("/assets", StaticFiles(directory=STATIC_DIR / "assets"), name="assets")