controller v0.121.0: backups page truth pass — remove dead Részletek card, real Tier-3 off-box state, SQLite-honest DB messaging

MinAgent: 0.81.0 (unchanged). Controller-only; no agent-API change, no backup-engine
behavior change. Fixes the self-contradicting /backups page (v0.120.0 live):

- Remove the dead "Részletek" card (redundant; kills never-set Tier2DriveGroups/
  ResticPassword fields + restic-pw element + toggleTier/toggleResticPw/copyResticPw JS).
- Per-app "3. mentés" row shows real off-box state via pure tier3State
  (unconfigured/off/escrow_pending/active) — "Hamarosan" placeholder gone.
- SQLite-honest DB messaging via pure dbSectionState (dumps/pending/embedded).
- Populate Tier1LastRun/Tier1LastStatus from ListRestorePoints; Tier-1/Tier-2 labels
  via timeAgoStr (relative), confirm() dialog keeps raw timestamp.
- Terminology split: "Távoli mentés (3. mentés)" (off-box, +#offbox-section anchor)
  vs "Távoli rendszermentés" (PBS whole-CT).
- Deploy page: add "Mentési beállítások →" link.

+9 internal/web tests (pure helper tables + buildAppBackupRows wiring + template
renders), 4 companion red-proofs run→fail→revert.
This commit is contained in:
2026-07-12 12:26:30 +02:00
parent 92d670e8a6
commit 9d05fa5c35
9 changed files with 604 additions and 174 deletions
+11 -4
View File
@@ -628,10 +628,15 @@ data back up config + DB + user data + Docker volumes; apps without HDD back up
**Protects against:** primary drive failure, drive theft/damage.
#### Tier 3: Remote Backup (future)
#### Tier 3: Off-box (NAS) Backup — live
Complete offsite backup for disaster recovery. Not yet implemented.
Placeholder shown in UI ("3. mentés — Hamarosan").
The off-site "1" of 3-2-1: each off-box-toggled app's recovery unit + DB dumps + volume tars are
backed up to the customer's NAS / Felhom offsite as an encrypted restic repo over SFTP (see the
off-box section below and `internal/backup/offbox.go`). The per-app "3. mentés" row on the backups
page renders one of four real states via the pure `tier3State` helper (`internal/web/backup_page_state.go`):
`unconfigured` (no target) / `off` (app not toggled) / `escrow_pending` (fork-4 key-escrow gate holds —
never a false success) / `active` (status badge + `restic → <host>` + relative last-run). Off-box run
status is repo-global (one `LastRun`); no per-app run time is fabricated.
#### Restore (`internal/backup/restore.go`)
@@ -697,7 +702,9 @@ Every app starts as yellow (1 tier only). Green requires Tier 2 configured with
- **2. mentes** (Tier 2, configurable for ALL apps) — one of:
- Configured: method (rsync/restic) + destination + schedule + last run + status + contents + browsable indicator (folder icon for rsync) + action buttons
- Not configured: "1. mentes auto" + "Nincs 2. masolat" + settings link
- **3. mentes** (Tier 3, placeholder) — grayed out "Hamarosan" + "tavoli (offsite)" + future note
- **3. mentes** (Tier 3, off-box/NAS — live) — one of four `tier3State` states: `unconfigured`
("Nincs beallitva" + Beallitas link), `off` ("Kikapcsolva" + Bekapcsolas link), `escrow_pending`
("Kulcsletetre var"), `active` (status badge + "restic -> <host>" + relative last-run)
**Backup contents per app** (shown per tier):
- Apps with DB + HDD: "DB + Konfig + Adatok"
@@ -0,0 +1,49 @@
package web
// backup_page_state holds the small pure state-pick helpers that drive the honest
// per-app / whole-page messaging on the /backups page. They are pure (no *Server,
// no I/O) so the truth-table can be unit-tested directly without a fixture Server.
// dbSectionState decides how the "Adatbázisok" section (and the "Adatbázis mentve"
// stat card) should read, given how many databases were discovered live at render
// time and how many dump files exist on disk:
// - "dumps" — dump files exist → show the real dump table / count.
// - "pending" — a database was discovered but no dump written yet → "first run tonight".
// - "embedded" — neither: the deployed apps carry embedded DBs (e.g. SQLite) that ride
// the file/volume backup; no separate dump is expected, so a bare "0" would lie.
//
// dumps wins over discovered: stale dumps from a since-removed DB app are still a real,
// restorable artifact and must be shown normally (see the §8 edge-case table).
func dbSectionState(discovered, dumps int) string {
switch {
case dumps > 0:
return "dumps"
case discovered > 0:
return "pending"
default:
return "embedded"
}
}
// tier3State decides the per-app "3. mentés" (off-box / off-site) row state:
// - "unconfigured" — no off-box target set (configured wins over a stale per-app toggle).
// - "off" — target set but this app is not toggled for off-box backup.
// - "escrow_pending" — toggled, but the repo password is not yet escrowed (fork-4 gate):
// runs are paused, so we must NOT imply a successful run.
// - "active" — toggled and escrowed: the app is included in the off-box runs.
//
// Precedence is strict: configured → toggle → escrow. Anything other than "escrowed"
// while toggled is treated as escrow-pending (never "active"), so a pre-pending LastStatus
// of "ok" can never surface a false "Sikeres".
func tier3State(configured, toggled bool, escrowState string) string {
switch {
case !configured:
return "unconfigured"
case !toggled:
return "off"
case escrowState != "escrowed":
return "escrow_pending"
default:
return "active"
}
}
@@ -0,0 +1,332 @@
package web
import (
"bytes"
"os"
"path/filepath"
"strings"
"testing"
"time"
"gitea.dooplex.hu/admin/felhom-controller/internal/backup"
"gitea.dooplex.hu/admin/felhom-controller/internal/settings"
)
// ---------------------------------------------------------------------------
// Pure state-pick helpers (Group C logic + tier3State precedence for Group B)
// ---------------------------------------------------------------------------
// TestDBSectionState — table-driven truth table for the embedded-DB-honest messaging pick.
// COMPANION red-proof: make dbSectionState ignore `discovered` (return "embedded" when dumps==0)
// → the (2,0)="pending" case below FAILS. Run → fail → revert (recorded in REPORT).
func TestDBSectionState(t *testing.T) {
cases := []struct {
discovered, dumps int
want string
}{
{0, 0, "embedded"}, // Scenario C: SQLite-only box — neither dump nor discovery
{2, 0, "pending"}, // discovered but no dump yet → "first run tonight" (NOT embedded)
{2, 3, "dumps"}, // real dumps present → show the table
{0, 3, "dumps"}, // stale dumps from a removed DB app still show (dumps wins)
}
for _, c := range cases {
if got := dbSectionState(c.discovered, c.dumps); got != c.want {
t.Errorf("dbSectionState(%d,%d) = %q, want %q", c.discovered, c.dumps, got, c.want)
}
}
}
// TestTier3State — the per-app off-box row state, with strict configured→toggle→escrow precedence.
func TestTier3State(t *testing.T) {
cases := []struct {
name string
configured bool
toggled bool
escrow string
want string
}{
{"unconfigured wins over stale toggle", false, true, "escrowed", "unconfigured"},
{"configured but app off", true, false, "escrowed", "off"},
{"toggled + escrowed → active", true, true, "escrowed", "active"},
{"toggled + pending escrow → escrow_pending", true, true, "pending", "escrow_pending"},
{"toggled + empty escrow → escrow_pending", true, true, "", "escrow_pending"},
}
for _, c := range cases {
if got := tier3State(c.configured, c.toggled, c.escrow); got != c.want {
t.Errorf("%s: tier3State(%v,%v,%q) = %q, want %q", c.name, c.configured, c.toggled, c.escrow, got, c.want)
}
}
}
// ---------------------------------------------------------------------------
// Handler wiring: buildAppBackupRows maps OffboxEnabled + Tier3State (Scenario A/B)
// ---------------------------------------------------------------------------
// configureOffbox sets up a real, configured off-box target (secrets + settings) so
// OffboxConfigured() reports true, with the given escrow state.
func configureOffbox(t *testing.T, sett *settings.Settings, m *backup.Manager, escrow string) {
t.Helper()
if err := m.WriteOffboxSecrets("KEYMATERIAL", "nas.local ssh-ed25519 HOSTKEY"); err != nil {
t.Fatal(err)
}
if err := sett.SetOffboxTarget(&settings.OffboxTarget{
Enabled: true, Host: "u629488-sub1.your-storagebox.de", Port: 22, User: "felhom",
RepoPath: "/home/repo", Schedule: "daily", EscrowState: escrow,
LastStatus: "ok", LastRun: "2026-07-11T02:00:00Z",
}); err != nil {
t.Fatal(err)
}
if !m.OffboxConfigured() {
t.Fatal("target should be configured")
}
}
func findRow(rows []AppBackupRow, stack string) *AppBackupRow {
for i := range rows {
if rows[i].StackName == stack {
return &rows[i]
}
}
return nil
}
// TestBuildAppBackupRows_OffboxMapping (Scenario A + B wiring): the per-app Tier-3 state is
// (global configured) × (global escrow) × (per-app toggle). calibre toggled ON → active; radarr
// OFF → off. COMPANION red-proof: hardcode row.OffboxEnabled=false in buildAppBackupRows → the
// calibre "active"/OffboxEnabled assertions FAIL. Run → fail → revert (recorded in REPORT).
func TestBuildAppBackupRows_OffboxMapping(t *testing.T) {
s, sett, m := newOffboxWebServer(t)
configureOffbox(t, sett, m, "escrowed")
if err := sett.SetAppOffbox("calibre-web", true); err != nil {
t.Fatal(err)
}
status := &backup.FullBackupStatus{AppDataInfo: []backup.AppBackupInfo{
{StackName: "calibre-web", DisplayName: "Calibre-Web"},
{StackName: "radarr", DisplayName: "Radarr"},
}}
rows := s.buildAppBackupRows(status)
cal := findRow(rows, "calibre-web")
if cal == nil || !cal.OffboxEnabled || cal.Tier3State != "active" {
t.Fatalf("calibre-web: OffboxEnabled/Tier3State wrong: %+v", cal)
}
rad := findRow(rows, "radarr")
if rad == nil || rad.OffboxEnabled || rad.Tier3State != "off" {
t.Fatalf("radarr: OffboxEnabled/Tier3State wrong: %+v", rad)
}
}
// TestBuildAppBackupRows_EscrowPendingPrecedence (Scenario B): a toggled app while escrow is
// pending is escrow_pending, never active — even though LastStatus is "ok" from a prior run.
func TestBuildAppBackupRows_EscrowPendingPrecedence(t *testing.T) {
s, sett, m := newOffboxWebServer(t)
configureOffbox(t, sett, m, "pending")
if err := sett.SetAppOffbox("calibre-web", true); err != nil {
t.Fatal(err)
}
rows := s.buildAppBackupRows(&backup.FullBackupStatus{AppDataInfo: []backup.AppBackupInfo{
{StackName: "calibre-web", DisplayName: "Calibre-Web"},
}})
cal := findRow(rows, "calibre-web")
if cal == nil || cal.Tier3State != "escrow_pending" {
t.Fatalf("escrow-pending must win over a prior ok run: %+v", cal)
}
}
// TestBuildAppBackupRows_Tier1FromRestorePoints (Scenario D): a recovery unit on disk → Tier1LastRun
// is its newest-artifact RFC3339 time; an app with no unit → Tier1LastRun stays "" (no fabrication).
// COMPANION red-proof: drop the ListRestorePoints assignment (leave Tier1LastRun unset) → the
// "with-unit" assertion FAILS. Run → fail → revert (recorded in REPORT).
func TestBuildAppBackupRows_Tier1FromRestorePoints(t *testing.T) {
s, _, m := newOffboxWebServer(t)
drive := filepath.Join(t.TempDir(), "drive")
m.SetStackProvider(&unitProvider{blockProvider{hdd: drive}})
// Write a recovery-unit manifest for "hasunit" with a known, decisively-past mtime.
manifest := backup.RecoveryUnitManifestPath(drive, "hasunit")
if err := os.MkdirAll(filepath.Dir(manifest), 0o755); err != nil {
t.Fatal(err)
}
if err := os.WriteFile(manifest, []byte("{}"), 0o644); err != nil {
t.Fatal(err)
}
mtime := time.Date(2026, 7, 10, 3, 30, 0, 0, time.UTC)
if err := os.Chtimes(manifest, mtime, mtime); err != nil {
t.Fatal(err)
}
rows := s.buildAppBackupRows(&backup.FullBackupStatus{AppDataInfo: []backup.AppBackupInfo{
{StackName: "hasunit", DisplayName: "Has Unit"},
{StackName: "nounit", DisplayName: "No Unit"},
}})
hu := findRow(rows, "hasunit")
if hu == nil || hu.Tier1LastRun != mtime.Format(time.RFC3339) {
t.Fatalf("hasunit Tier1LastRun = %q, want %q", huTier1(hu), mtime.Format(time.RFC3339))
}
if hu.Tier1LastStatus != "ok" {
t.Errorf("hasunit Tier1LastStatus = %q, want ok", hu.Tier1LastStatus)
}
nu := findRow(rows, "nounit")
if nu == nil || nu.Tier1LastRun != "" {
t.Fatalf("nounit must have NO fabricated Tier1LastRun, got %q", huTier1(nu))
}
}
func huTier1(r *AppBackupRow) string {
if r == nil {
return "<nil row>"
}
return r.Tier1LastRun
}
// unitProvider makes every stack resolvable (GetStackComposePath ok) with the embedded hdd drive,
// so ListRestorePoints resolves the namespace to that drive.
type unitProvider struct{ blockProvider }
func (u *unitProvider) GetStackComposePath(string) (string, bool) { return "compose", true }
// ---------------------------------------------------------------------------
// Template rendering (Group A/B/C/D): the real "backups" template tree
// ---------------------------------------------------------------------------
func renderBackups(t *testing.T, data map[string]interface{}) string {
t.Helper()
s := testServer(t)
s.loadTemplates()
var buf bytes.Buffer
if err := s.tmpl.ExecuteTemplate(&buf, "backups", data); err != nil {
t.Fatalf("render backups: %v", err)
}
return buf.String()
}
// baseBackupData is the minimal data map that makes the "backups" body render (Backup truthy +
// one AppDataInfo so Section 4/7 appear). Callers overlay AppBackupRows / Offbox / DBSectionState.
func baseBackupData(rows []AppBackupRow) map[string]interface{} {
return map[string]interface{}{
"Page": "backups", "Title": "Biztonsági mentés",
"Backup": &backup.FullBackupStatus{
AppDataInfo: []backup.AppBackupInfo{{StackName: "calibre-web", DisplayName: "Calibre-Web"}},
},
"AppBackupRows": rows,
"DBSectionState": "dumps",
}
}
// TestBackupsTemplate_Tier3Live (Scenario A) — active + off rows render truthfully, and every
// removed marker is gone. COMPANION red-proof: re-insert "hamarosan elérhető" into the tier-3 block
// → the no-"hamarosan" assertion FAILS. Run → fail → revert (recorded in REPORT).
func TestBackupsTemplate_Tier3Live(t *testing.T) {
data := baseBackupData([]AppBackupRow{
{StackName: "calibre-web", DisplayName: "Calibre-Web", OffboxEnabled: true, Tier3State: "active"},
{StackName: "radarr", DisplayName: "Radarr", OffboxEnabled: false, Tier3State: "off"},
})
data["Offbox"] = &settings.OffboxTarget{
Enabled: true, Host: "u629488-sub1.your-storagebox.de", LastStatus: "ok",
LastRun: "2026-07-11T02:00:00Z", EscrowState: "escrowed",
}
data["OffboxConfigured"] = true
html := renderBackups(t, data)
for _, want := range []string{
"Sikeres", // active badge (LastStatus ok)
"restic → u629488-sub1.your-storagebox.de", // the real off-box host
"Utolsó:", // a relative last-run time is shown
"Kikapcsolva", // radarr off row
"Bekapcsolás", // radarr enable link
`href="#offbox-section"`, // the anchor jump target
"Távoli mentés (3. mentés)", // the renamed section header
} {
if !strings.Contains(html, want) {
t.Errorf("rendered page missing %q", want)
}
}
for _, banned := range []string{
"hamarosan", // the dead placeholder copy
"Tier2DriveGroups", // dead template field
"ResticPassword", // dead template field
"restic-pw", // dead element id
"toggleTier", // dead JS fn
"details-tier", // dead Részletek markup
"Részletek", // the removed card title
"2026-07-11T02:00:00Z", // raw RFC3339 must never leak (timeAgoStr wraps it)
} {
if strings.Contains(html, banned) {
t.Errorf("rendered page still contains removed/raw marker %q", banned)
}
}
}
// TestBackupsTemplate_Tier3EscrowPending (Scenario B) — the escrow-pending row shows the wait
// state and NOT a false success. The single row carries no Tier-2, so "Sikeres" would only come
// from a (wrong) tier-3 active badge.
func TestBackupsTemplate_Tier3EscrowPending(t *testing.T) {
data := baseBackupData([]AppBackupRow{
{StackName: "calibre-web", DisplayName: "Calibre-Web", OffboxEnabled: true, Tier3State: "escrow_pending"},
})
data["Offbox"] = &settings.OffboxTarget{Enabled: true, Host: "nas.local", LastStatus: "ok", EscrowState: "pending"}
data["OffboxConfigured"] = true
html := renderBackups(t, data)
if !strings.Contains(html, "Kulcsletétre vár") {
t.Error("escrow-pending row must show 'Kulcsletétre vár'")
}
// The active-state marker must be absent — no false success. (Bare "Sikeres" would
// false-match the "Sikeresen törölve" JS toast, so assert the active contents string.)
if strings.Contains(html, "Helyreállítási egység, titkosítva") {
t.Error("escrow-pending must NOT render the active tier-3 row (false success)")
}
}
// TestBackupsTemplate_DBMessaging (Scenario C) — embedded vs pending messaging in the stat card
// and the Adatbázisok empty state.
func TestBackupsTemplate_DBMessaging(t *testing.T) {
t.Run("embedded", func(t *testing.T) {
data := baseBackupData(nil)
data["DBSectionState"] = "embedded"
html := renderBackups(t, data)
for _, want := range []string{
"beágyazott DB-k a kötetmentésben", // stat-card sublabel
"beágyazott adatbázist használnak", // Adatbázisok empty-state explanation
} {
if !strings.Contains(html, want) {
t.Errorf("embedded page missing %q", want)
}
}
if strings.Contains(html, "Nem található adatbázis mentés.") {
t.Error("embedded box must NOT show the old bare 'not found' message")
}
})
t.Run("pending", func(t *testing.T) {
data := baseBackupData(nil)
data["DBSectionState"] = "pending"
html := renderBackups(t, data)
if !strings.Contains(html, "az első ütemezett mentés éjjel fut le") {
t.Error("pending page missing the 'first run tonight' message")
}
if strings.Contains(html, "beágyazott adatbázist használnak") {
t.Error("pending box must NOT show the embedded-DB message")
}
})
}
// TestBackupsTemplate_Tier2RelativeTime (Scenario D) — a Tier-2 last-run renders as relative time,
// never the raw RFC3339 literal.
func TestBackupsTemplate_Tier2RelativeTime(t *testing.T) {
data := baseBackupData([]AppBackupRow{{
StackName: "calibre-web", DisplayName: "Calibre-Web",
Tier2Configured: true, Tier2Dest: "USB", Tier2Schedule: "Naponta",
Tier2LastRun: "2026-07-10T03:30:00Z", Tier2LastStatus: "ok", Tier2StatusBadge: "Sikeres",
Tier3State: "unconfigured",
}})
html := renderBackups(t, data)
// The visible "Utolsó:" label must be a relative time, never the raw RFC3339. (The raw
// timestamp legitimately survives in the restore confirm() dialog — precise there by design.)
if strings.Contains(html, "Utolsó: 2026-07-10T03:30:00Z") {
t.Error("Tier-2 last-run label must render via timeAgoStr, not the raw RFC3339 literal")
}
if !strings.Contains(html, "Utolsó:") {
t.Error("Tier-2 row should still show an 'Utolsó:' label")
}
}
+36 -1
View File
@@ -653,6 +653,10 @@ func (s *Server) backupsHandler(w http.ResponseWriter, r *http.Request) {
data["Backup"] = fullStatus
// DB-section state — honest messaging for embedded-DB-only boxes (SQLite etc.):
// "dumps" (real dumps) | "pending" (discovered, first run tonight) | "embedded".
data["DBSectionState"] = dbSectionState(len(fullStatus.DiscoveredDBs), len(fullStatus.DumpFiles))
// DB dump total size
var dbDumpTotalBytes int64
for _, f := range fullStatus.DumpFiles {
@@ -719,7 +723,7 @@ type AppBackupRow struct {
BackupContents string
// Tier 1: Nightly backup (always exists)
Tier1LastRun string // formatted time of last restic snapshot
Tier1LastRun string // RFC3339 time of the newest recovery-unit artifact ("" = no unit yet)
Tier1LastStatus string // "ok", "error", ""
Tier1DBStatus string // "ok", "error", "" — separate DB dump status for warning
@@ -742,6 +746,10 @@ type AppBackupRow struct {
// Tier2UserDisabled — customer turned Tier 2 off for this app from the config panel.
Tier2UserDisabled bool
// Tier 3: Off-box (NAS) restic-SFTP backup — the off-site 3-2-1 leg.
OffboxEnabled bool // this app toggled for off-box inclusion (IsAppOffbox)
Tier3State string // "unconfigured" | "off" | "escrow_pending" | "active" (see tier3State)
// Warnings accumulated for this app
Warnings []string
}
@@ -774,6 +782,14 @@ func (s *Server) buildAppBackupRows(status *backup.FullBackupStatus) []AppBackup
disconnectedPaths[dp.Path] = true
}
// Off-box (Tier 3) globals — resolved once for all rows. The per-app state is
// (global configured) × (global escrow) × (per-app toggle); see tier3State.
offboxConfigured := s.backupMgr != nil && s.backupMgr.OffboxConfigured()
offboxEscrowState := ""
if t := s.settings.GetOffboxTarget(); t != nil {
offboxEscrowState = t.EscrowState
}
var rows []AppBackupRow
for _, app := range status.AppDataInfo {
hasDB := dbStacks[app.StackName] || app.HasDBDump
@@ -818,6 +834,25 @@ func (s *Server) buildAppBackupRows(status *backup.FullBackupStatus) []AppBackup
Tier1DBStatus: tier1DBStatus,
}
// Tier 1: newest recovery-unit artifact time. ListRestorePoints does the correct
// per-drive namespace resolution (do NOT re-derive paths — the offbox DIAG trap).
// A known stack with no unit yet returns an empty list → no fabricated time.
if s.backupMgr != nil {
if pts, ok := s.backupMgr.ListRestorePoints(app.StackName); ok && len(pts) > 0 {
row.Tier1LastRun = pts[0].Time
// A unit exists: green unless the DB dump failed (keep tier1DBStatus as the source).
if status.LastDBDump != nil && !status.LastDBDump.Success {
row.Tier1LastStatus = "error"
} else {
row.Tier1LastStatus = "ok"
}
}
}
// Tier 3: off-box (NAS) inclusion state for this app.
row.OffboxEnabled = s.settings.IsAppOffbox(app.StackName)
row.Tier3State = tier3State(offboxConfigured, row.OffboxEnabled, offboxEscrowState)
// Status dot — app-data backup status
row.Status = "green"
row.StatusText = "Alkalmazás-adat mentés rendben"
+48 -111
View File
@@ -125,8 +125,8 @@
{{if .Backup}}
<!-- Off-box (NAS) backup — Part B: encrypted restic repo over SFTP (the off-site 3-2-1 leg). -->
<h3 class="backup-tier-divider">Külső (NAS) mentés — titkosított, off-site</h3>
<p class="form-hint" style="margin:-0.25rem 0 1rem">Az alkalmazások adatainak + adatbázis-kiírásainak titkosított mentése a saját NAS-odra (restic, SFTP-n). A NAS csak titkosított adatot lát. Ez a 3-2-1 „1 off-site" lába — független a helyi másodpéldánytól és a teljes rendszermentéstől.</p>
<h3 id="offbox-section" class="backup-tier-divider">Távoli mentés (3. mentés) — titkosított, offsite</h3>
<p class="form-hint" style="margin:-0.25rem 0 1rem">Az alkalmazás-mentések titkosított másolata egy távoli tárolóra — saját NAS vagy Felhom offsite tárhely — restic + SFTP kapcsolaton. A tároló csak titkosított adatot lát. Ez a 3-2-1 szabály „1 off-site" lába — független a helyi másodpéldánytól és a teljes rendszermentéstől.</p>
<div class="card" style="margin-bottom:1.5rem">
{{if .Offbox}}
<div class="stats-grid backup-page-cards">
@@ -245,20 +245,25 @@
{{if and .GuestBackup .GuestBackup.Offsite}}
<div class="stat-card stat-running">
<div class="stat-value">&#10003;</div>
<div class="stat-label">Távoli mentés<br><span class="relative-time">külön hardveren (PBS)</span></div>
<div class="stat-label">Távoli rendszermentés<br><span class="relative-time">külön hardveren (PBS)</span></div>
</div>
{{else}}
<div class="stat-card" style="border-left-color: var(--text-3);">
<div class="stat-value" style="background:var(--text-3);-webkit-background-clip:text;background-clip:text;"></div>
<div class="stat-label">Távoli mentés<br><span class="relative-time">nincs beállítva</span></div>
<div class="stat-label">Távoli rendszermentés<br><span class="relative-time">nincs beállítva</span></div>
</div>
{{end}}
<div class="stat-card stat-total">
{{if eq .DBSectionState "embedded"}}
<div class="stat-value"></div>
<div class="stat-label">Adatbázis mentve<br><span class="relative-time">beágyazott DB-k a kötetmentésben</span></div>
{{else}}
<div class="stat-value">
{{if .Backup.LastDBDump}}{{len .Backup.LastDBDump.Results}}{{else}}{{len .Backup.DumpFiles}}{{end}}
</div>
<div class="stat-label">Adatbázis mentve</div>
{{end}}
</div>
</div>
@@ -360,8 +365,10 @@
</tbody>
</table>
</div>
{{else if eq .DBSectionState "pending"}}
<div class="backup-table-empty">Még nem készült adatbázis-mentés — az első ütemezett mentés éjjel fut le.</div>
{{else}}
<div class="backup-table-empty">Nem található adatbázis mentés.</div>
<div class="backup-table-empty">A telepített alkalmazások beágyazott adatbázist használnak (pl. SQLite) — adatbázisuk a fájl- és kötetmentés része, külön adatbázis-kiírás nem szükséges.</div>
{{end}}
</div>
@@ -406,7 +413,7 @@
<span class="layer-badge">Auto</span>
<span class="tier-location">helyi</span>
{{if .Tier1LastRun}}
<span class="layer-last">Utolsó: {{.Tier1LastRun}}
<span class="layer-last">Utolsó: {{timeAgoStr .Tier1LastRun}}
{{if eq .Tier1LastStatus "ok"}}<span class="text-ok"><svg class="ico ico-sm"><use href="#i-check"/></svg></span>
{{else if eq .Tier1LastStatus "error"}}<span class="text-error"><svg class="ico ico-sm"><use href="#i-x"/></svg></span>{{end}}
</span>
@@ -429,7 +436,7 @@
<span class="layer-dest" style="opacity:.6">→ {{.Tier2Dest}}</span>
<span class="tag tag-warn">Cél meghajtó leválasztva</span>
{{if .Tier2LastRun}}
<span class="layer-last" style="opacity:.6">Utolsó: {{.Tier2LastRun}}</span>
<span class="layer-last" style="opacity:.6">Utolsó: {{timeAgoStr .Tier2LastRun}}</span>
{{end}}
<span class="tier-contents" style="opacity:.6">{{.BackupContents}}</span>
<div class="layer-actions">
@@ -440,7 +447,7 @@
<span class="layer-dest" style="opacity:.6">→ {{.Tier2Dest}}</span>
<span class="tag tag-warn">Cél meghajtó inaktív</span>
{{if .Tier2LastRun}}
<span class="layer-last" style="opacity:.6">Utolsó: {{.Tier2LastRun}}</span>
<span class="layer-last" style="opacity:.6">Utolsó: {{timeAgoStr .Tier2LastRun}}</span>
{{end}}
<span class="tier-contents" style="opacity:.6">{{.BackupContents}}</span>
<div class="layer-actions">
@@ -451,7 +458,7 @@
<span class="layer-dest">→ {{.Tier2Dest}}</span>
<span class="layer-schedule">{{.Tier2Schedule}}</span>
{{if .Tier2LastRun}}
<span class="layer-last">Utolsó: {{.Tier2LastRun}}
<span class="layer-last">Utolsó: {{timeAgoStr .Tier2LastRun}}
<span class="{{if eq .Tier2LastStatus "ok"}}text-ok{{else if eq .Tier2LastStatus "error"}}text-error{{else if eq .Tier2LastStatus "running"}}text-muted{{end}}">
{{.Tier2StatusBadge}}
</span>
@@ -480,13 +487,41 @@
</div>
{{end}}
</div>
<!-- Tier 3: Remote backup (future) -->
<!-- Tier 3: Off-box (NAS) backup — real state (see tier3State). -->
{{if eq .Tier3State "active"}}
<div class="backup-layer-row">
<span class="tier-label">3. mentés</span>
<span class="layer-badge {{if eq $.Offbox.LastStatus "ok"}}text-ok{{else if eq $.Offbox.LastStatus "error"}}text-error{{else if eq $.Offbox.LastStatus "running"}}text-muted{{end}}">{{if eq $.Offbox.LastStatus "ok"}}Sikeres{{else if eq $.Offbox.LastStatus "error"}}Hiba{{else if eq $.Offbox.LastStatus "running"}}Fut...{{else}}—{{end}}</span>
<span class="tier-location">restic → {{$.Offbox.Host}}</span>
{{if $.Offbox.LastRun}}<span class="layer-last">Utolsó: {{timeAgoStr $.Offbox.LastRun}}</span>{{end}}
<span class="tier-contents">Helyreállítási egység, titkosítva</span>
</div>
{{else if eq .Tier3State "escrow_pending"}}
<div class="backup-layer-row">
<span class="tier-label">3. mentés</span>
<span class="layer-badge text-error">Kulcsletétre vár</span>
<span class="tier-contents">A távoli mentés a titkosítási kulcs letétbe helyezéséig szünetel</span>
</div>
{{else if eq .Tier3State "off"}}
<div class="backup-layer-row" style="opacity:.5">
<span class="tier-label">3. mentés</span>
<span class="layer-badge" style="background:var(--bg-2);color:var(--text-3)">Hamarosan</span>
<span class="tier-location">távoli (offsite)</span>
<span class="tier-contents" style="font-style:normal;color:var(--text-3)">B2 / S3 / SFTP — hamarosan elérhető</span>
<span class="layer-badge">Kikapcsolva</span>
<span class="tier-contents">Ez az alkalmazás nincs kijelölve távoli mentésre</span>
<div class="layer-actions">
<a href="#offbox-section" class="btn btn-xs btn-outline">Bekapcsolás</a>
</div>
</div>
{{else}}
<div class="backup-layer-row" style="opacity:.5">
<span class="tier-label">3. mentés</span>
<span class="layer-badge" style="background:var(--bg-2);color:var(--text-3)">Nincs beállítva</span>
<span class="tier-location">távoli (offsite)</span>
<span class="tier-contents">Nincs távoli mentési cél beállítva</span>
<div class="layer-actions">
<a href="#offbox-section" class="btn btn-xs btn-outline">Beállítás</a>
</div>
</div>
{{end}}
</div>
{{if .Warnings}}
<div class="layer-warnings">
@@ -502,78 +537,6 @@
</div>
{{end}}
<!-- Section 6: Részletek (Details) -->
<div class="repo-card">
<h3>Részletek</h3>
<!-- Tier 1: Helyi mentés (collapsible, open by default) -->
<div class="details-tier">
<div class="details-tier-header" onclick="toggleTier(this)">
<span class="expand-icon"></span>
<h4 class="repo-tier-title">1. szint — Helyi mentés (adatbázis + konfiguráció)</h4>
</div>
<div class="details-tier-body">
<div class="repo-info-rows" style="margin-top:0.5rem">
<div class="repo-info-row">
<span class="repo-label">Adatbázis mentések:</span>
<span class="repo-value">{{if .Backup.DumpFiles}}{{len .Backup.DumpFiles}} dump fájl{{if gt .DBDumpTotalBytes 0}} — {{fmtBytes .DBDumpTotalBytes}}{{end}}{{else}}Nincs dump fájl{{end}}</span>
</div>
</div>
<!-- Encryption key -->
{{if $.ResticPassword}}
<div class="repo-encryption">
<span class="repo-label">Titkosítási kulcs:</span>
<div class="repo-encryption-row">
<input type="password" id="restic-pw" class="restic-pw-field mono" value="{{$.ResticPassword}}" readonly>
<button type="button" class="btn btn-sm" onclick="toggleResticPw()">Megjelenítés</button>
<button type="button" class="btn btn-sm" onclick="copyResticPw()">Másolás</button>
</div>
<div class="repo-encryption-warn">
Mentse el biztonságos helyre! A kulcs nélkül a biztonsági mentések NEM állíthatók vissza.
</div>
</div>
{{end}}
</div>
</div>
<!-- Tier 2: Másodlagos másolat (collapsible, collapsed by default) -->
<div class="details-tier">
<div class="details-tier-header" onclick="toggleTier(this)">
<span class="expand-icon"></span>
<h4 class="repo-tier-title">2. szint — Másodlagos másolat</h4>
</div>
<div class="details-tier-body" style="display:none">
{{if .Tier2DriveGroups}}
{{range .Tier2DriveGroups}}
<div class="drive-detail-card">
<div class="drive-detail-header">{{.DestLabel}} <span class="relative-time mono">({{.DestPath}})</span></div>
{{range .Items}}
<div class="repo-info-row">
<span class="repo-label">{{.DisplayName}}</span>
<span class="repo-value">{{if .SizeHuman}}{{.SizeHuman}}{{else}}—{{end}}</span>
</div>
{{end}}
</div>
{{end}}
{{else}}
<div class="tier-empty-state">Nincs 2. szintű mentés konfigurálva.</div>
{{end}}
</div>
</div>
<!-- Tier 3: Távoli mentés (collapsible, collapsed by default, placeholder) -->
<div class="details-tier">
<div class="details-tier-header" onclick="toggleTier(this)">
<span class="expand-icon"></span>
<h4 class="repo-tier-title" style="opacity:.6">3. szint — Távoli mentés (offsite)</h4>
</div>
<div class="details-tier-body" style="display:none">
<div class="tier-empty-state">B2 / S3 / SFTP — hamarosan elérhető</div>
</div>
</div>
</div>
<!-- Section 7: Restore -->
{{if .Backup.AppDataInfo}}
<div class="backup-section-card">
@@ -671,18 +634,6 @@ function toggleBackupDetail(header) {
}
}
function toggleTier(header) {
var body = header.nextElementSibling;
var icon = header.querySelector('.expand-icon');
if (body.style.display === 'none') {
body.style.display = 'block';
icon.textContent = '▼';
} else {
body.style.display = 'none';
icon.textContent = '▶';
}
}
function triggerBackupFromPage() {
const btn = document.getElementById('backup-page-btn');
btn.disabled = true;
@@ -756,20 +707,6 @@ function pollGuestBackup(out, btn) {
}, 5000);
}
// Restic password toggle/copy
function toggleResticPw() {
var el = document.getElementById('restic-pw');
el.type = el.type === 'password' ? 'text' : 'password';
}
function copyResticPw() {
var el = document.getElementById('restic-pw');
navigator.clipboard.writeText(el.value).then(function() {
var btn = event.target;
btn.textContent = 'Másolva!';
setTimeout(function() { btn.textContent = 'Másolás'; }, 2000);
});
}
// Restore section
var huDays = ['vasárnap', 'hétfő', 'kedd', 'szerda', 'csütörtök', 'péntek', 'szombat'];
function formatSnapshot(s) {
@@ -113,7 +113,7 @@
<div class="cross-drive-nightly">
<span class="form-hint" style="display:block;margin-top:.25rem">
Az alkalmazás adatbázisa és Docker kötetei automatikusan bekerülnek az éjszakai biztonsági mentésbe.
<a href="/backups" style="color:var(--blue)">Mentési állapot →</a>
<a href="/backups" style="color:var(--blue)">Mentési állapot →</a> · <a href="/stacks/{{.Stack.Name}}/backup" style="color:var(--blue)">Mentési beállítások →</a>
</span>
</div>
</div>