feat: Borg-Archivhistorie je Host abfragen
This commit is contained in:
parent
be01f03d3b
commit
7166ad9499
1 changed files with 22 additions and 0 deletions
22
app.py
22
app.py
|
|
@ -603,6 +603,28 @@ async def backup_break_lock(hostname: str, _=Depends(_verify)):
|
||||||
return {"status": "lock_broken", "hostname": hostname, "detail": out.strip()[-4000:]}
|
return {"status": "lock_broken", "hostname": hostname, "detail": out.strip()[-4000:]}
|
||||||
|
|
||||||
|
|
||||||
|
@app.get("/backup/history/{hostname}")
|
||||||
|
async def backup_history(hostname: str, _=Depends(_verify)):
|
||||||
|
"""Return the ten newest Borg archives for one inventory host."""
|
||||||
|
host = await asyncio.to_thread(_find_inventory_host, hostname)
|
||||||
|
if not host or host["name"].startswith("node"):
|
||||||
|
return JSONResponse({"error": "inventory host not found"}, status_code=404)
|
||||||
|
rc, out, err = await asyncio.to_thread(
|
||||||
|
_ssh, f'{host["user"]}@{host["ip"]}',
|
||||||
|
"sudo -n borgmatic list --last 10 --json", 120
|
||||||
|
)
|
||||||
|
if rc != 0:
|
||||||
|
return JSONResponse(
|
||||||
|
{"error": "borg list failed", "hostname": hostname,
|
||||||
|
"stdout": out[-4000:], "stderr": err[-4000:]}, status_code=500
|
||||||
|
)
|
||||||
|
try:
|
||||||
|
history = json.loads(out)
|
||||||
|
except (TypeError, ValueError):
|
||||||
|
return JSONResponse({"error": "invalid borg JSON", "hostname": hostname}, status_code=500)
|
||||||
|
return {"hostname": hostname, "history": history}
|
||||||
|
|
||||||
|
|
||||||
@app.get("/backup/run-status/{hostname}")
|
@app.get("/backup/run-status/{hostname}")
|
||||||
async def backup_run_status(hostname: str, _=Depends(_verify)):
|
async def backup_run_status(hostname: str, _=Depends(_verify)):
|
||||||
"""Lightweight current backup service state and recent logs."""
|
"""Lightweight current backup service state and recent logs."""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue