Add per-backup status dot (green/yellow/red/unknown) to the UI

backup-k8s-apps.sh now tracks step-level failures (manifests, secret,
db_dump, pvc_data) into an ERRORS array during the per-app loop, and
writes a .meta.json sidecar alongside each archive once all 3 storage
tiers are known - apps included, final size, the error list, and
per-tier ok/failed/skipped status. Sidecar is mirrored to VM/R2 the
same best-effort way the .sha256 sidecar already is, and cleaned up
by both local and R2 retention pruning plus manual delete.

modules/backups.py reads these sidecars (never decompresses the
archive) to compute a status per backup at list-render time:
  - red: any recorded error, or any tier status starting with "failed"
  - yellow: no errors, but size deviates >40% from the rolling average
    of the last 5 backups sharing the same app-combination (apps_key)
  - green: no errors, size within range (or first backup of its
    app-combination - nothing to compare against yet)
  - unknown: no sidecar at all (legacy myapps-backup-* archives, or
    any k8s backup made before this shipped) - no backfill attempted,
    old runs never recorded step-level failures to reconstruct from

/backups route now passes get_local_backups_with_status()/
get_vm_backups_with_status() instead of the plain filename lists
(get_local_backups()/get_vm_backups() themselves are untouched -
/restore and /api/backups still use the plain versions, they don't
need the dot). Template renders a colored dot next to each entry with
a tooltip showing apps/size.

Verified: real n8n backup produces a correct sidecar synced to all 3
tiers; JSON-writer argv parsing and the red/yellow/green/unknown
decision logic each checked against synthetic cases; full Jinja render
checked against real local + VM data pulled from the live pod.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017avLHFqkiti3g62Anq9sVA
This commit is contained in:
root
2026-08-21 02:46:50 +02:00
parent de0b1ee4db
commit d498c81d5b
5 changed files with 265 additions and 27 deletions

View File

@@ -881,7 +881,7 @@ a.sidebar-brand-link {
box-shadow: var(--glow-accent);
}
.backup-item-main { min-width: 0; padding-bottom: 12px; }
.backup-item-main { min-width: 0; padding-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.backup-item:not(:has(.backup-actions)) .backup-item-main { padding-bottom: 0; }
.backup-name {
@@ -894,6 +894,18 @@ a.sidebar-brand-link {
}
.backup-name i { margin-right: 6px; opacity: 0.85; }
/* Backup status dot — green/yellow/red from the .meta.json sidecar
backup-k8s-apps.sh writes; gray for backups with no sidecar (legacy
archives, or anything made before this feature shipped). */
.status-dot {
width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
border: 1px solid rgba(0,0,0,0.15);
}
.status-dot-green { background: var(--green); box-shadow: 0 0 6px rgba(45,212,122,0.5); }
.status-dot-yellow { background: var(--yellow); box-shadow: 0 0 6px rgba(245,185,66,0.5); }
.status-dot-red { background: var(--red); box-shadow: 0 0 6px rgba(240,82,82,0.5); }
.status-dot-unknown { background: var(--text3); box-shadow: none; }
.backup-meta {
display: block;
margin-top: 6px;