controller: backups IA split — four sub-pages (Áttekintés /backups, Távoli mentés /backups/remote, Alkalmazások /backups/apps, Visszaállítás /backups/restore); sections MOVED verbatim (backups_split_move_check.py enforces vs df7ad37); shared data builder extracted; offbox restore-to-verify relocated to the restore page; flash redirects + tier-3 anchors + tier2 back-link retargeted
Claude-Session: https://claude.ai/code/session_01GzammAMzsJTgpQHqxwM2bC
This commit is contained in:
@@ -191,12 +191,18 @@ func (u *unitProvider) GetStackComposePath(string) (string, bool) { return "comp
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
func renderBackups(t *testing.T, data map[string]interface{}) string {
|
||||
return renderBackupPage(t, "backups", data)
|
||||
}
|
||||
|
||||
// renderBackupPage renders one of the four backups sub-page templates (v0.124.0 IA split)
|
||||
// through the PRODUCTION template tree.
|
||||
func renderBackupPage(t *testing.T, page string, 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)
|
||||
if err := s.tmpl.ExecuteTemplate(&buf, page, data); err != nil {
|
||||
t.Fatalf("render %s: %v", page, err)
|
||||
}
|
||||
return buf.String()
|
||||
}
|
||||
@@ -227,7 +233,7 @@ func TestBackupsTemplate_Tier3Live(t *testing.T) {
|
||||
LastRun: "2026-07-11T02:00:00Z", EscrowState: "escrowed",
|
||||
}
|
||||
data["OffboxConfigured"] = true
|
||||
html := renderBackups(t, data)
|
||||
html := renderBackupPage(t, "backups_apps", data)
|
||||
|
||||
for _, want := range []string{
|
||||
"Sikeres", // active badge (LastStatus ok)
|
||||
@@ -235,11 +241,19 @@ func TestBackupsTemplate_Tier3Live(t *testing.T) {
|
||||
"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
|
||||
`href="/backups/remote#offbox-section"`, // the cross-page anchor jump target (IA split)
|
||||
} {
|
||||
if !strings.Contains(html, want) {
|
||||
t.Errorf("rendered page missing %q", want)
|
||||
t.Errorf("rendered apps page missing %q", want)
|
||||
}
|
||||
}
|
||||
remoteHTML := renderBackupPage(t, "backups_remote", data)
|
||||
for _, want := range []string{
|
||||
"Távoli mentés (3. mentés)", // the renamed section header
|
||||
`id="offbox-section"`, // the anchor target the apps-page links jump to
|
||||
} {
|
||||
if !strings.Contains(remoteHTML, want) {
|
||||
t.Errorf("rendered remote page missing %q", want)
|
||||
}
|
||||
}
|
||||
for _, banned := range []string{
|
||||
@@ -267,7 +281,7 @@ func TestBackupsTemplate_Tier3EscrowPending(t *testing.T) {
|
||||
})
|
||||
data["Offbox"] = &settings.OffboxTarget{Enabled: true, Host: "nas.local", LastStatus: "ok", EscrowState: "pending"}
|
||||
data["OffboxConfigured"] = true
|
||||
html := renderBackups(t, data)
|
||||
html := renderBackupPage(t, "backups_apps", data)
|
||||
|
||||
if !strings.Contains(html, "Kulcsletétre vár") {
|
||||
t.Error("escrow-pending row must show 'Kulcsletétre vár'")
|
||||
@@ -285,23 +299,22 @@ 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)
|
||||
}
|
||||
overviewHTML := renderBackups(t, data)
|
||||
if !strings.Contains(overviewHTML, "beágyazott DB-k a kötetmentésben") { // stat-card sublabel
|
||||
t.Error("embedded overview page missing the stat-card sublabel")
|
||||
}
|
||||
if strings.Contains(html, "Nem található adatbázis mentés.") {
|
||||
appsHTML := renderBackupPage(t, "backups_apps", data)
|
||||
if !strings.Contains(appsHTML, "beágyazott adatbázist használnak") { // Adatbázisok empty state
|
||||
t.Error("embedded apps page missing the Adatbázisok explanation")
|
||||
}
|
||||
if strings.Contains(appsHTML, "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)
|
||||
html := renderBackupPage(t, "backups_apps", data)
|
||||
if !strings.Contains(html, "az első ütemezett mentés éjjel fut le") {
|
||||
t.Error("pending page missing the 'first run tonight' message")
|
||||
}
|
||||
@@ -320,7 +333,7 @@ func TestBackupsTemplate_Tier2RelativeTime(t *testing.T) {
|
||||
Tier2LastRun: "2026-07-10T03:30:00Z", Tier2LastStatus: "ok", Tier2StatusBadge: "Sikeres",
|
||||
Tier3State: "unconfigured",
|
||||
}})
|
||||
html := renderBackups(t, data)
|
||||
html := renderBackupPage(t, "backups_apps", 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") {
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"gitea.dooplex.hu/admin/felhom-controller/internal/backup"
|
||||
"gitea.dooplex.hu/admin/felhom-controller/internal/settings"
|
||||
)
|
||||
|
||||
// v0.124.0 IA split (§10 nav/state): each backups sub-page renders ONLY its mapped sections —
|
||||
// a marker string per section, asserted present on its page and absent on every other page.
|
||||
|
||||
func splitTestData() 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": []AppBackupRow{
|
||||
{StackName: "calibre-web", DisplayName: "Calibre-Web", OffboxEnabled: true, Tier3State: "active"},
|
||||
},
|
||||
"DBSectionState": "dumps",
|
||||
"Offbox": &settings.OffboxTarget{
|
||||
Enabled: true, Host: "nas.local", LastStatus: "ok", EscrowState: "escrowed",
|
||||
},
|
||||
"OffboxConfigured": true,
|
||||
"OffboxApps": []OffboxAppRow{{Name: "calibre-web", DisplayName: "Calibre-Web", Enabled: true}},
|
||||
"OffboxToggledCount": 1,
|
||||
"OffboxQuotaPct": 0,
|
||||
"GuestBackup": map[string]interface{}{"Available": false, "Note": "n/a"},
|
||||
}
|
||||
}
|
||||
|
||||
func TestBackupsSplit_SectionsOnExactlyOnePage(t *testing.T) {
|
||||
pages := map[string]string{
|
||||
"backups": renderBackupPage(t, "backups", splitTestData()),
|
||||
"backups_remote": renderBackupPage(t, "backups_remote", splitTestData()),
|
||||
"backups_apps": renderBackupPage(t, "backups_apps", splitTestData()),
|
||||
"backups_restore": renderBackupPage(t, "backups_restore", splitTestData()),
|
||||
}
|
||||
|
||||
// marker → the ONE page it belongs to
|
||||
markers := map[string]string{
|
||||
"Tárhely áttekintés": "backups", // Section 0
|
||||
"Rendszermentés (teljes mentés)": "backups", // whole-guest
|
||||
">Adatmentés<": "backups", // stat cards (neutral branch)
|
||||
`id="offbox-section"`: "backups_remote", // the offbox anchor target
|
||||
"Távoli mentési cél beállítása": "backups_remote", // manual-target form
|
||||
"Mely alkalmazások mentődnek": "backups_remote", // toggle list
|
||||
"<h3>Ütemezés</h3>": "backups_apps", // schedule
|
||||
"<h3>Adatbázisok</h3>": "backups_apps", // databases
|
||||
"Alkalmazások mentési állapota": "backups_apps", // per-app rows
|
||||
`id="restore-app"`: "backups_restore", // restore panel
|
||||
"Ellenőrző visszaállítás a távoli tárolóból": "backups_restore", // moved restore-to-verify
|
||||
`action="/backup/offbox/restore"`: "backups_restore", // the MOVED form itself
|
||||
}
|
||||
for marker, home := range markers {
|
||||
for page, html := range pages {
|
||||
has := strings.Contains(html, marker)
|
||||
if page == home && !has {
|
||||
t.Errorf("%s: missing its own section marker %q", page, marker)
|
||||
}
|
||||
if page != home && has {
|
||||
t.Errorf("%s: renders %q which belongs to %s only", page, marker, home)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The tier-3 row actions must deep-link cross-page to the offbox section (the pre-split
|
||||
// #offbox-section anchors would be orphaned on the apps page).
|
||||
func TestBackupsSplit_CrossPageAnchors(t *testing.T) {
|
||||
data := splitTestData()
|
||||
data["AppBackupRows"] = []AppBackupRow{
|
||||
{StackName: "radarr", DisplayName: "Radarr", Tier3State: "off"},
|
||||
}
|
||||
html := renderBackupPage(t, "backups_apps", data)
|
||||
if !strings.Contains(html, `href="/backups/remote#offbox-section"`) {
|
||||
t.Error("tier-3 'Bekapcsolás' must link cross-page to /backups/remote#offbox-section")
|
||||
}
|
||||
if strings.Contains(html, `href="#offbox-section"`) {
|
||||
t.Error("orphaned same-page #offbox-section anchor survives on the apps page")
|
||||
}
|
||||
}
|
||||
|
||||
// Route → handler wiring: each sub-route sets its own .Page id, so the sidebar child renders
|
||||
// active on the right page (backupMgr nil → the empty state renders, the nav still does).
|
||||
func TestBackupsSplit_RoutesSetPageIDs(t *testing.T) {
|
||||
s := testServer(t)
|
||||
s.loadTemplates()
|
||||
|
||||
cases := []struct {
|
||||
path string
|
||||
active string
|
||||
}{
|
||||
{"/backups/remote", `href="/backups/remote" class="active"`},
|
||||
{"/backups/apps", `href="/backups/apps" class="active"`},
|
||||
{"/backups/restore", `href="/backups/restore" class="active"`},
|
||||
}
|
||||
for _, c := range cases {
|
||||
rr := httptest.NewRecorder()
|
||||
req := httptest.NewRequest("GET", c.path, nil)
|
||||
switch c.path {
|
||||
case "/backups/remote":
|
||||
s.backupsRemoteHandler(rr, req)
|
||||
case "/backups/apps":
|
||||
s.backupsAppsHandler(rr, req)
|
||||
case "/backups/restore":
|
||||
s.backupsRestoreHandler(rr, req)
|
||||
}
|
||||
if rr.Code != 200 {
|
||||
t.Fatalf("%s: status %d", c.path, rr.Code)
|
||||
}
|
||||
if !strings.Contains(rr.Body.String(), c.active) {
|
||||
t.Errorf("%s: sidebar child not active (want %q)", c.path, c.active)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -612,8 +612,55 @@ func isPingConfigured(uuid string) bool {
|
||||
return uuid != "" && !strings.HasPrefix(uuid, "CHANGEME")
|
||||
}
|
||||
|
||||
// backupsCommonData builds what every backups sub-page shares (v0.124.0 IA split): the page
|
||||
// chrome + the backup full-status with the redirect flash. Backup stays nil (empty-state) when
|
||||
// the manager is absent. Each page handler adds ONLY the data its sections render — no
|
||||
// duplicated computation across the four pages.
|
||||
func (s *Server) backupsCommonData(page, title string, r *http.Request) map[string]interface{} {
|
||||
data := s.baseData(page, title)
|
||||
if s.backupMgr == nil {
|
||||
data["Backup"] = nil
|
||||
return data
|
||||
}
|
||||
nextDBDump := scheduler.NextDailyRun(s.cfg.Backup.DBDumpSchedule)
|
||||
fullStatus := s.backupMgr.GetFullStatus(nextDBDump)
|
||||
|
||||
// Pass flash messages from query params (set by redirect handlers)
|
||||
if flash := r.URL.Query().Get("flash"); flash != "" {
|
||||
fullStatus.FlashSuccess = flash
|
||||
}
|
||||
if flashErr := r.URL.Query().Get("flash_error"); flashErr != "" {
|
||||
fullStatus.FlashError = flashErr
|
||||
}
|
||||
data["Backup"] = fullStatus
|
||||
return data
|
||||
}
|
||||
|
||||
// backupsOffboxData adds the offbox target + per-app toggle state (the remote, apps and restore
|
||||
// pages all render some of it: status card / toggle list / tier-3 rows / restore-to-verify).
|
||||
func (s *Server) backupsOffboxData(data map[string]interface{}) {
|
||||
offboxTgt := s.settings.GetOffboxTarget()
|
||||
data["Offbox"] = offboxTgt
|
||||
data["OffboxConfigured"] = s.backupMgr != nil && s.backupMgr.OffboxConfigured()
|
||||
offboxApps := s.buildOffboxApps()
|
||||
data["OffboxApps"] = offboxApps
|
||||
// Zero-toggle hint (take-two obs.): configured + escrowed but no app selected — nothing is
|
||||
// actually covered by the offsite leg until the customer toggles at least one.
|
||||
offboxToggled := 0
|
||||
for _, a := range offboxApps {
|
||||
if a.Enabled {
|
||||
offboxToggled++
|
||||
}
|
||||
}
|
||||
data["OffboxToggledCount"] = offboxToggled
|
||||
// SLICE 4 soft-quota usage bar (rendered only when a quota is set — shared model).
|
||||
data["OffboxQuotaPct"] = backup.OffboxQuotaPercent(offboxTgt)
|
||||
}
|
||||
|
||||
// backupsHandler renders the Áttekintés page: storage overview, whole-guest Rendszermentés and
|
||||
// the status stat cards.
|
||||
func (s *Server) backupsHandler(w http.ResponseWriter, r *http.Request) {
|
||||
data := s.baseData("backups", "Biztonsági mentés")
|
||||
data := s.backupsCommonData("backups", "Biztonsági mentés", r)
|
||||
|
||||
// System info for storage overview bars
|
||||
data["SystemInfo"] = system.GetInfo(s.primaryHDDPath(), s.cpuCollector)
|
||||
@@ -622,18 +669,30 @@ func (s *Server) backupsHandler(w http.ResponseWriter, r *http.Request) {
|
||||
// Whole-guest backup view (agent-sourced, read-only) for the "Rendszermentés" section.
|
||||
data["GuestBackup"] = s.loadGuestBackup(r.Context())
|
||||
|
||||
if s.backupMgr != nil {
|
||||
nextDBDump := scheduler.NextDailyRun(s.cfg.Backup.DBDumpSchedule)
|
||||
fullStatus := s.backupMgr.GetFullStatus(nextDBDump)
|
||||
if fullStatus, ok := data["Backup"].(*backup.FullBackupStatus); ok && fullStatus != nil {
|
||||
// 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))
|
||||
}
|
||||
|
||||
// Pass flash messages from query params (set by redirect handlers)
|
||||
if flash := r.URL.Query().Get("flash"); flash != "" {
|
||||
fullStatus.FlashSuccess = flash
|
||||
}
|
||||
if flashErr := r.URL.Query().Get("flash_error"); flashErr != "" {
|
||||
fullStatus.FlashError = flashErr
|
||||
}
|
||||
s.executeTemplate(w, r, "backups", data)
|
||||
}
|
||||
|
||||
// backupsRemoteHandler renders the Távoli mentés page: the Felhom-offsite status card, the
|
||||
// participation toggles and the manual-target form.
|
||||
func (s *Server) backupsRemoteHandler(w http.ResponseWriter, r *http.Request) {
|
||||
data := s.backupsCommonData("backups-remote", "Biztonsági mentés — Távoli mentés", r)
|
||||
s.backupsOffboxData(data)
|
||||
s.executeTemplate(w, r, "backups_remote", data)
|
||||
}
|
||||
|
||||
// backupsAppsHandler renders the Alkalmazások page: schedule, databases and the per-app
|
||||
// 1./2./3. tier rows.
|
||||
func (s *Server) backupsAppsHandler(w http.ResponseWriter, r *http.Request) {
|
||||
data := s.backupsCommonData("backups-apps", "Biztonsági mentés — Alkalmazások", r)
|
||||
s.backupsOffboxData(data) // the tier-3 rows render $.Offbox status
|
||||
|
||||
if fullStatus, ok := data["Backup"].(*backup.FullBackupStatus); ok && fullStatus != nil {
|
||||
// Enrich AppDataInfo with storage labels
|
||||
storagePaths := s.settings.GetStoragePaths()
|
||||
for i := range fullStatus.AppDataInfo {
|
||||
@@ -653,42 +712,18 @@ func (s *Server) backupsHandler(w http.ResponseWriter, r *http.Request) {
|
||||
// Build unified per-app backup rows for the app-data backup UI.
|
||||
// Disk-tier (cross-drive / restic) backup has moved to the host agent.
|
||||
data["AppBackupRows"] = s.buildAppBackupRows(fullStatus)
|
||||
|
||||
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 {
|
||||
dbDumpTotalBytes += f.Size
|
||||
}
|
||||
data["DBDumpTotalBytes"] = dbDumpTotalBytes
|
||||
|
||||
// Off-box (NAS) restic-SFTP backup (Part B): the target status + per-app off-box toggles.
|
||||
offboxTgt := s.settings.GetOffboxTarget()
|
||||
data["Offbox"] = offboxTgt
|
||||
data["OffboxConfigured"] = s.backupMgr.OffboxConfigured()
|
||||
offboxApps := s.buildOffboxApps()
|
||||
data["OffboxApps"] = offboxApps
|
||||
// Zero-toggle hint (take-two obs.): configured + escrowed but no app selected — nothing is
|
||||
// actually covered by the offsite leg until the customer toggles at least one.
|
||||
offboxToggled := 0
|
||||
for _, a := range offboxApps {
|
||||
if a.Enabled {
|
||||
offboxToggled++
|
||||
}
|
||||
}
|
||||
data["OffboxToggledCount"] = offboxToggled
|
||||
// SLICE 4 soft-quota usage bar (rendered only when a quota is set — shared model).
|
||||
data["OffboxQuotaPct"] = backup.OffboxQuotaPercent(offboxTgt)
|
||||
} else {
|
||||
data["Backup"] = nil
|
||||
}
|
||||
|
||||
s.executeTemplate(w, r, "backups", data)
|
||||
s.executeTemplate(w, r, "backups_apps", data)
|
||||
}
|
||||
|
||||
// backupsRestoreHandler renders the Visszaállítás page: the restore panel, the offbox
|
||||
// restore-to-verify list and the .fab export/import loop.
|
||||
func (s *Server) backupsRestoreHandler(w http.ResponseWriter, r *http.Request) {
|
||||
data := s.backupsCommonData("backups-restore", "Biztonsági mentés — Visszaállítás", r)
|
||||
s.backupsOffboxData(data) // restore-to-verify lists the offbox-toggled apps
|
||||
s.executeTemplate(w, r, "backups_restore", data)
|
||||
}
|
||||
|
||||
// OffboxAppRow is one deployed app's off-box toggle state for the backups page.
|
||||
@@ -930,26 +965,26 @@ func (s *Server) backupRestoreHandler(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
if stackName == "" || snapshotID == "" {
|
||||
http.Redirect(w, r, "/backups?flash_error=Hi%C3%A1nyz%C3%B3+param%C3%A9terek", http.StatusFound)
|
||||
http.Redirect(w, r, "/backups/restore?flash_error=Hi%C3%A1nyz%C3%B3+param%C3%A9terek", http.StatusFound)
|
||||
return
|
||||
}
|
||||
// F2 (defense-in-depth): a stack name is a single segment, never a path. Reject traversal before any
|
||||
// restore work — never let it reach RestoreFromRecoveryUnit.
|
||||
if !validStackName(stackName) {
|
||||
s.logger.Printf("[WARN] [web] restore rejected: invalid stack_name %q from %s", stackName, r.RemoteAddr)
|
||||
http.Redirect(w, r, "/backups?flash_error=%C3%89rv%C3%A9nytelen+alkalmaz%C3%A1sn%C3%A9v", http.StatusFound)
|
||||
http.Redirect(w, r, "/backups/restore?flash_error=%C3%89rv%C3%A9nytelen+alkalmaz%C3%A1sn%C3%A9v", http.StatusFound)
|
||||
return
|
||||
}
|
||||
|
||||
if s.backupMgr == nil {
|
||||
http.Redirect(w, r, "/backups?flash_error=Ment%C3%A9s+nincs+be%C3%A1ll%C3%ADtva", http.StatusFound)
|
||||
http.Redirect(w, r, "/backups/restore?flash_error=Ment%C3%A9s+nincs+be%C3%A1ll%C3%ADtva", http.StatusFound)
|
||||
return
|
||||
}
|
||||
// Part B: restore is a long SYNCHRONOUS op (F4 — through cloudflared's hard 100s cap the customer
|
||||
// got an error page while it silently succeeded). Fast-path refuse a concurrent op, then run it in
|
||||
// a BACKGROUND goroutine (survives the request; the poll banner shows progress → result).
|
||||
if s.backupMgr.IsRunning() {
|
||||
http.Redirect(w, r, "/backups?flash_error="+url.QueryEscape("Egy mentési/visszaállítási művelet már fut."), http.StatusFound)
|
||||
http.Redirect(w, r, "/backups/restore?flash_error="+url.QueryEscape("Egy mentési/visszaállítási művelet már fut."), http.StatusFound)
|
||||
return
|
||||
}
|
||||
s.logger.Printf("[WARN] [web] Restore requested (async): stack=%s, snapshot=%s from %s", stackName, snapshotID, r.RemoteAddr)
|
||||
@@ -966,7 +1001,7 @@ func (s *Server) backupRestoreHandler(w http.ResponseWriter, r *http.Request) {
|
||||
s.logger.Printf("[INFO] [web] Restore completed (async): stack=%s in %s", stackName, time.Since(start))
|
||||
s.backupMgr.EndRestoreOp(true, stackName+" visszaállítva ("+snapshotID+").")
|
||||
}()
|
||||
http.Redirect(w, r, "/backups?flash="+url.QueryEscape("Visszaállítás elindult — az állapot itt frissül."), http.StatusFound)
|
||||
http.Redirect(w, r, "/backups/restore?flash="+url.QueryEscape("Visszaállítás elindult — az állapot itt frissül."), http.StatusFound)
|
||||
}
|
||||
|
||||
// backupTier2RestoreHandler (C2, closes F2) restores an app's MISSING user files in place from its
|
||||
@@ -977,22 +1012,22 @@ func (s *Server) backupTier2RestoreHandler(w http.ResponseWriter, r *http.Reques
|
||||
stackName := r.FormValue("stack_name")
|
||||
|
||||
if stackName == "" {
|
||||
http.Redirect(w, r, "/backups?flash_error=Hi%C3%A1nyz%C3%B3+param%C3%A9terek", http.StatusFound)
|
||||
http.Redirect(w, r, "/backups/apps?flash_error=Hi%C3%A1nyz%C3%B3+param%C3%A9terek", http.StatusFound)
|
||||
return
|
||||
}
|
||||
// Same F2-defense as the unit restore: a stack name is a single segment, never a path.
|
||||
if !validStackName(stackName) {
|
||||
s.logger.Printf("[WARN] [web] Tier-2 file restore rejected: invalid stack_name %q from %s", stackName, r.RemoteAddr)
|
||||
http.Redirect(w, r, "/backups?flash_error=%C3%89rv%C3%A9nytelen+alkalmaz%C3%A1sn%C3%A9v", http.StatusFound)
|
||||
http.Redirect(w, r, "/backups/apps?flash_error=%C3%89rv%C3%A9nytelen+alkalmaz%C3%A1sn%C3%A9v", http.StatusFound)
|
||||
return
|
||||
}
|
||||
if s.backupMgr == nil {
|
||||
http.Redirect(w, r, "/backups?flash_error=Ment%C3%A9s+nincs+be%C3%A1ll%C3%ADtva", http.StatusFound)
|
||||
http.Redirect(w, r, "/backups/apps?flash_error=Ment%C3%A9s+nincs+be%C3%A1ll%C3%ADtva", http.StatusFound)
|
||||
return
|
||||
}
|
||||
// Part B (same async shape as backupRestoreHandler): fast-path refuse, then background goroutine.
|
||||
if s.backupMgr.IsRunning() {
|
||||
http.Redirect(w, r, "/backups?flash_error="+url.QueryEscape("Egy mentési/visszaállítási művelet már fut."), http.StatusFound)
|
||||
http.Redirect(w, r, "/backups/apps?flash_error="+url.QueryEscape("Egy mentési/visszaállítási művelet már fut."), http.StatusFound)
|
||||
return
|
||||
}
|
||||
s.logger.Printf("[WARN] [web] Tier-2 file restore requested (async): stack=%s from %s", stackName, r.RemoteAddr)
|
||||
@@ -1011,7 +1046,7 @@ func (s *Server) backupTier2RestoreHandler(w http.ResponseWriter, r *http.Reques
|
||||
s.logger.Printf("[INFO] [web] Tier-2 file restore completed (async): stack=%s (%d files)", stackName, n)
|
||||
s.backupMgr.EndRestoreOp(true, msg)
|
||||
}()
|
||||
http.Redirect(w, r, "/backups?flash="+url.QueryEscape("Fájl-visszaállítás elindult — az állapot itt frissül."), http.StatusFound)
|
||||
http.Redirect(w, r, "/backups/apps?flash="+url.QueryEscape("Fájl-visszaállítás elindult — az állapot itt frissül."), http.StatusFound)
|
||||
}
|
||||
|
||||
// settingsBaseData is the shared identity block used by every settings-family subpage
|
||||
|
||||
@@ -17,13 +17,19 @@ import (
|
||||
// The SSH private key + known-host line are provided out-of-band by the operator (textareas) and written
|
||||
// to 0600/0644 files by the backup Manager; they are NEVER echoed back, logged, or stored in settings.
|
||||
|
||||
// offboxRedirect sends the operator back to the backups page with a flash (success or error) message.
|
||||
// offboxRedirect sends the customer back to the Távoli mentés page with a flash (success or
|
||||
// error) message (v0.124.0 IA split: the offbox controls live on /backups/remote; the
|
||||
// restore-to-verify flow redirects to /backups/restore via offboxRedirectTo).
|
||||
func offboxRedirect(w http.ResponseWriter, r *http.Request, msg string, isErr bool) {
|
||||
offboxRedirectTo(w, r, "/backups/remote", msg, isErr)
|
||||
}
|
||||
|
||||
func offboxRedirectTo(w http.ResponseWriter, r *http.Request, page, msg string, isErr bool) {
|
||||
q := "flash"
|
||||
if isErr {
|
||||
q = "flash_error"
|
||||
}
|
||||
http.Redirect(w, r, "/backups?"+q+"="+url.QueryEscape(msg), http.StatusFound)
|
||||
http.Redirect(w, r, page+"?"+q+"="+url.QueryEscape(msg), http.StatusFound)
|
||||
}
|
||||
|
||||
// offboxConfigHandler saves the off-box target + (out-of-band) SSH key + known_hosts.
|
||||
@@ -211,20 +217,20 @@ func (s *Server) offboxRunHandler(w http.ResponseWriter, r *http.Request) {
|
||||
// overwrite live data; the operator inspects the restored files).
|
||||
func (s *Server) offboxRestoreHandler(w http.ResponseWriter, r *http.Request) {
|
||||
if s.backupMgr == nil || !s.backupMgr.OffboxConfigured() {
|
||||
offboxRedirect(w, r, "A távoli mentési cél nincs beállítva.", true)
|
||||
offboxRedirectTo(w, r, "/backups/restore", "A távoli mentési cél nincs beállítva.", true)
|
||||
return
|
||||
}
|
||||
_ = r.ParseForm()
|
||||
app := strings.TrimSpace(r.FormValue("app"))
|
||||
if app == "" {
|
||||
offboxRedirect(w, r, "Hiányzó alkalmazás.", true)
|
||||
offboxRedirectTo(w, r, "/backups/restore", "Hiányzó alkalmazás.", true)
|
||||
return
|
||||
}
|
||||
// Part B: fast-path refuse a concurrent op, then run async on a BACKGROUND context. The old code
|
||||
// bounded on r.Context()+30m — a proxy read-timeout then CANCELED the SFTP restore mid-flight
|
||||
// (worse than F4: not just an error page, an aborted restore). Background ctx fixes that.
|
||||
if s.backupMgr.IsRunning() {
|
||||
offboxRedirect(w, r, "Egy mentési/visszaállítási művelet már fut.", true)
|
||||
offboxRedirectTo(w, r, "/backups/restore", "Egy mentési/visszaállítási művelet már fut.", true)
|
||||
return
|
||||
}
|
||||
dest := filepath.Join(s.cfg.Paths.DataDir, "offbox-restore", app)
|
||||
@@ -240,5 +246,5 @@ func (s *Server) offboxRestoreHandler(w http.ResponseWriter, r *http.Request) {
|
||||
s.logger.Printf("[INFO] [web] off-box restore %s completed (async) → %s", app, dest)
|
||||
s.backupMgr.EndRestoreOp(true, "A(z) "+app+" visszaállítva ide (ellenőrzésre): "+dest)
|
||||
}()
|
||||
offboxRedirect(w, r, "A távoli visszaállítás elindult — az állapot itt frissül.", false)
|
||||
offboxRedirectTo(w, r, "/backups/restore", "A távoli visszaállítás elindult — az állapot itt frissül.", false)
|
||||
}
|
||||
|
||||
@@ -293,6 +293,14 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
s.stacksHandler(w, r)
|
||||
case path == "/backups":
|
||||
s.backupsHandler(w, r)
|
||||
// v0.124.0 IA split: the backups page's four sub-pages (old /backups deep links keep working —
|
||||
// /backups itself is the Áttekintés page).
|
||||
case path == "/backups/remote":
|
||||
s.backupsRemoteHandler(w, r)
|
||||
case path == "/backups/apps":
|
||||
s.backupsAppsHandler(w, r)
|
||||
case path == "/backups/restore":
|
||||
s.backupsRestoreHandler(w, r)
|
||||
case path == "/monitoring":
|
||||
s.monitoringHandler(w, r)
|
||||
case path == "/settings":
|
||||
|
||||
@@ -6,27 +6,13 @@
|
||||
<span class="domain-badge">{{.Domain}}</span>
|
||||
</div>
|
||||
|
||||
{{if .Backup}}{{if .Backup.FlashSuccess}}
|
||||
<div class="flash flash-success">{{.Backup.FlashSuccess}}</div>
|
||||
{{end}}{{end}}
|
||||
{{if .Backup}}{{if .Backup.FlashError}}
|
||||
<div class="flash flash-error">{{.Backup.FlashError}}</div>
|
||||
{{end}}{{end}}
|
||||
{{template "backups_flash" .}}
|
||||
{{if .Backup}}{{if .Backup.SingleCopyWarning}}
|
||||
<div class="alert alert-warning">{{.Backup.SingleCopyWarning}}</div>
|
||||
{{end}}{{end}}
|
||||
|
||||
<!-- Part B: async restore progress banner — polls /api/backup/restore-status; neutral while running,
|
||||
red only on failure (exception-color principle). Hidden until a restore op is seen. -->
|
||||
<div id="restore-banner" class="flash" style="display:none"></div>
|
||||
|
||||
{{if not .Backup}}
|
||||
<div class="backup-empty-state">
|
||||
<div class="backup-empty-icon">🛡</div>
|
||||
<h3>Biztonsági mentés nincs beállítva</h3>
|
||||
<p>A biztonsági mentés funkció nem aktív.<br>
|
||||
Kérjük, vegye fel a kapcsolatot a Felhom csapattal a beállításhoz.</p>
|
||||
</div>
|
||||
{{template "backups_empty" .}}
|
||||
{{else}}
|
||||
|
||||
<!-- Section 0: Storage overview -->
|
||||
@@ -123,107 +109,6 @@
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
{{if .Backup}}
|
||||
<!-- Off-box (NAS) backup — Part B: encrypted restic repo over SFTP (the off-site 3-2-1 leg). -->
|
||||
<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">
|
||||
<div class="stat-card {{if eq .Offbox.LastStatus "error"}}stat-warn{{end}}">
|
||||
<div class="stat-value" style="font-size:1.15rem">{{if eq .Offbox.LastStatus "ok"}}✓ Rendben{{else if eq .Offbox.LastStatus "error"}}✗ Hiba{{else if eq .Offbox.LastStatus "running"}}Fut…{{else}}–{{end}}</div>
|
||||
<div class="stat-label">Utolsó távoli mentés{{if .Offbox.LastRun}}<br><span class="relative-time">{{timeAgoStr .Offbox.LastRun}}</span>{{end}}</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-value" style="font-size:1.15rem">{{if .Offbox.RepoSizeHuman}}{{.Offbox.RepoSizeHuman}}{{else}}–{{end}}</div>
|
||||
<div class="stat-label">Tároló méret · {{.Offbox.SnapshotCount}} pillanatkép</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-value" style="font-size:1.05rem">{{if .Offbox.Enabled}}{{.Offbox.User}}@{{.Offbox.Host}}{{else}}Kikapcsolva{{end}}</div>
|
||||
<div class="stat-label">{{if .Offbox.Enabled}}{{.Offbox.RepoPath}}{{else}}A távoli mentés ki van kapcsolva{{end}}</div>
|
||||
</div>
|
||||
</div>
|
||||
{{if and .Offbox.Enabled (gt .Offbox.QuotaGB 0)}}
|
||||
<!-- SLICE 4: soft-quota usage bar (shared model; quota_gb from the hub descriptor). -->
|
||||
<div id="offbox-quota-bar" style="max-width:560px;margin:.5rem 0">
|
||||
<div class="stat-label" style="margin-bottom:.25rem">Tárhelykeret: {{if .Offbox.RepoSizeHuman}}{{.Offbox.RepoSizeHuman}}{{else}}0{{end}} / {{.Offbox.QuotaGB}} GB ({{.OffboxQuotaPct}}%)</div>
|
||||
<div style="background:var(--border,#334);border-radius:4px;height:8px;overflow:hidden">
|
||||
<div style="height:8px;border-radius:4px;width:{{.OffboxQuotaPct}}%;background:{{if ge .OffboxQuotaPct 100}}var(--crit,#e5484d){{else if ge .OffboxQuotaPct 80}}var(--warn,#f5a524){{else}}var(--ok,#30a46c){{end}}"></div>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
{{if .Offbox.LastError}}<p class="form-hint" style="color:var(--crit)">Utolsó hiba: {{.Offbox.LastError}}</p>{{end}}
|
||||
{{if .Offbox.LastWarning}}<p class="form-hint" style="color:var(--warn)">{{.Offbox.LastWarning}}</p>{{end}}
|
||||
{{if and .OffboxConfigured (ne .Offbox.EscrowState "escrowed")}}
|
||||
<div class="card" style="border-left:3px solid var(--warn);margin:.75rem 0;padding:.75rem 1rem">
|
||||
<p class="form-hint" style="color:var(--warn);margin:0 0 .5rem">A távoli mentés a kulcs letétbe helyezésére vár — a mentés addig nem fut (így nem keletkezik visszaállíthatatlan másolat). Futtasd a letéti szertartást, majd erősítsd meg.</p>
|
||||
<form method="POST" action="/backup/offbox/confirm-escrow" style="display:inline">{{.CSRFField}}
|
||||
<button type="submit" class="btn btn-sm">Letét megerősítése</button>
|
||||
</form>
|
||||
</div>
|
||||
{{end}}
|
||||
{{if .OffboxConfigured}}
|
||||
<div class="schedule-actions" style="margin-top:1rem">
|
||||
<form method="POST" action="/backup/offbox/run" style="display:inline">{{.CSRFField}}
|
||||
<button type="submit" class="btn btn-sm btn-primary">Távoli mentés most</button>
|
||||
</form>
|
||||
</div>
|
||||
<h4 style="margin-top:1.25rem">Mely alkalmazások mentődnek a távoli tárolóra?</h4>
|
||||
{{if and .OffboxApps (eq .Offbox.EscrowState "escrowed") (eq .OffboxToggledCount 0)}}
|
||||
<p class="form-hint">Nincs távoli mentésre jelölt alkalmazás — jelölj ki legalább egyet.</p>
|
||||
{{end}}
|
||||
{{if .OffboxApps}}
|
||||
<div class="storage-paths-list">
|
||||
{{range .OffboxApps}}
|
||||
<div class="storage-path-item">
|
||||
<div class="storage-path-header">
|
||||
<div class="storage-path-info"><span class="storage-path-label">{{.DisplayName}}</span></div>
|
||||
<div class="storage-path-actions">
|
||||
<form method="POST" action="/backup/offbox/toggle" style="display:inline">{{$.CSRFField}}
|
||||
<input type="hidden" name="app" value="{{.Name}}">
|
||||
<input type="hidden" name="enabled" value="{{if .Enabled}}false{{else}}true{{end}}">
|
||||
<button type="submit" class="btn btn-xs {{if .Enabled}}btn-outline{{else}}btn-primary{{end}}">{{if .Enabled}}Távoli mentés kikapcsolása{{else}}Távoli mentés bekapcsolása{{end}}</button>
|
||||
</form>
|
||||
{{if .Enabled}}
|
||||
<form method="POST" action="/backup/offbox/restore" style="display:inline">{{$.CSRFField}}
|
||||
<input type="hidden" name="app" value="{{.Name}}">
|
||||
<button type="submit" class="btn btn-xs btn-outline" data-confirm="Visszaállítja a(z) {{.DisplayName}} adatait a távoli tárolóról egy ellenőrző mappába? A meglévő adatok NEM íródnak felül.">Visszaállítás (ellenőrzéshez)</button>
|
||||
</form>
|
||||
{{end}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
{{else}}<p class="form-hint">Nincs telepített alkalmazás.</p>{{end}}
|
||||
{{end}}
|
||||
{{else}}
|
||||
<p class="form-hint">Még nincs beállítva távoli mentési cél.</p>
|
||||
{{end}}
|
||||
|
||||
<details style="margin-top:1rem">
|
||||
<summary class="btn btn-xs btn-primary" style="cursor:pointer;display:inline-block">Távoli mentési cél beállítása</summary>
|
||||
<form method="POST" action="/backup/offbox/config" style="margin-top:.75rem;padding:1rem;border:1px solid var(--border,#ddd);border-radius:6px;max-width:560px">{{.CSRFField}}
|
||||
<div class="form-row"><label>Cél címe (IP vagy hosztnév — NAS vagy SFTP-kiszolgáló)</label><input type="text" name="host" class="form-input" value="{{if .Offbox}}{{.Offbox.Host}}{{end}}" placeholder="pl. 192.168.0.10"></div>
|
||||
<div class="form-row"><label>SSH port</label><input type="number" name="port" class="form-input" value="{{if .Offbox}}{{.Offbox.Port}}{{else}}22{{end}}"></div>
|
||||
<div class="form-row"><label>Felhasználó</label><input type="text" name="user" class="form-input" value="{{if .Offbox}}{{.Offbox.User}}{{end}}" placeholder="pl. felhom"></div>
|
||||
<div class="form-row"><label>Tároló útvonala a célgépen</label><input type="text" name="repo_path" class="form-input" value="{{if .Offbox}}{{.Offbox.RepoPath}}{{end}}" placeholder="pl. /volume1/felhom-backup/repo"></div>
|
||||
<div class="form-row"><label><input type="checkbox" name="enabled" {{if .Offbox}}{{if .Offbox.Enabled}}checked{{end}}{{else}}checked{{end}}> Napi automatikus távoli mentés engedélyezve</label></div>
|
||||
<div class="form-row"><label>SSH privát kulcs {{if .OffboxConfigured}}(üresen hagyva változatlan){{end}}</label>
|
||||
<textarea name="ssh_key" class="form-input" rows="4" autocomplete="off" placeholder="-----BEGIN OPENSSH PRIVATE KEY-----"></textarea>
|
||||
<span class="form-hint">A kulcsot 0600-as fájlba írjuk; sosem naplózzuk és nem tároljuk a beállításokban.</span></div>
|
||||
<div class="form-row"><label>A célgép ismert-host sora (known_hosts) {{if .OffboxConfigured}}(üresen hagyva változatlan){{end}}</label>
|
||||
<textarea name="known_hosts" class="form-input" rows="2" autocomplete="off" placeholder="nas.local ssh-ed25519 AAAA…"></textarea>
|
||||
<span class="form-hint">A host-kulcs rögzítése (no blind TOFU). Lekérdezhető: <span class="mono">ssh-keyscan -p <port> <host></span></span></div>
|
||||
<button type="submit" class="btn btn-sm btn-primary" style="margin-top:.5rem">Mentés</button>
|
||||
</form>
|
||||
</details>
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
<h3 class="backup-tier-divider">Alkalmazás-mentések (adatbázis + konfiguráció)</h3>
|
||||
<p class="form-hint" style="margin:-0.25rem 0 1rem">Az egyes alkalmazások részletes, granulált mentése — adatbázis-kiírások, beállítások és alkalmazás-fájlok. A fenti teljes mentéstől függetlenül, alkalmazásonként visszaállítható.</p>
|
||||
|
||||
<!-- Section 1: Status overview cards -->
|
||||
<div class="stats-grid backup-page-cards">
|
||||
{{if .Backup.LastDBDump}}
|
||||
@@ -270,409 +155,9 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Section 2: Schedule -->
|
||||
<div class="schedule-card">
|
||||
<h3>Ütemezés</h3>
|
||||
<div class="schedule-rows">
|
||||
<div class="schedule-row">
|
||||
<span class="schedule-task">Adatbázis mentés</span>
|
||||
<span class="schedule-time">{{.Backup.DBDumpSchedule}}</span>
|
||||
<span class="schedule-next">Következő: {{nextRunLabel .Backup.NextDBDump}}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="schedule-summary">
|
||||
{{if .Backup.LastDBDump}}
|
||||
<div class="schedule-summary-row">
|
||||
<span>Utolsó adatbázis mentés:</span>
|
||||
<span class="schedule-summary-value">{{fmtTime .Backup.LastDBDump.LastRun}} ({{timeAgo .Backup.LastDBDump.LastRun}})</span>
|
||||
</div>
|
||||
{{else}}
|
||||
<div class="schedule-summary-row">
|
||||
<span>Utolsó adatbázis mentés:</span>
|
||||
<span class="schedule-summary-value relative-time">Még nem futott</span>
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
<div class="schedule-actions">
|
||||
<button class="btn btn-sm btn-primary" onclick="triggerBackupFromPage()" id="backup-page-btn"
|
||||
{{if .Backup.Running}}disabled{{end}}>
|
||||
{{if .Backup.Running}}Mentés folyamatban...{{else}}Mentés most{{end}}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Section 3: Databases -->
|
||||
<div class="backup-section-card">
|
||||
<h3>Adatbázisok</h3>
|
||||
{{if or .Backup.DumpFiles .Backup.DiscoveredDBs}}
|
||||
<div class="backup-table-wrap">
|
||||
<table class="db-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Alkalmazás</th>
|
||||
<th>Típus</th>
|
||||
<th>Méret</th>
|
||||
<th>Utolsó</th>
|
||||
<th>Érvényesítés</th>
|
||||
<th>Állapot</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{if .Backup.LastDBDump}}
|
||||
{{range .Backup.LastDBDump.Results}}
|
||||
<tr>
|
||||
<td>{{.DB.StackName}}</td>
|
||||
<td><span class="db-type-badge db-type-{{.DB.DBType}}">{{dbTypeLabel .DB.DBType}}</span></td>
|
||||
<td class="mono">{{if .Error}}–{{else}}{{fmtBytes .Size}}{{end}}</td>
|
||||
<td class="mono">{{if .Error}}–{{else}}{{fmtTimeShort $.Backup.LastDBDump.LastRun}}{{end}}</td>
|
||||
<td>
|
||||
{{if .Error}}
|
||||
<span class="validation-badge validation-na">–</span>
|
||||
{{else if .Validation.Valid}}
|
||||
<span class="validation-badge validation-ok">{{.Validation.TableCount}} tábla</span>
|
||||
{{else if .Validation.Error}}
|
||||
<span class="validation-badge validation-fail" title="{{.Validation.Error}}">Hiba</span>
|
||||
{{else}}
|
||||
<span class="validation-badge validation-na" title="Az érvényesítés nem futott le">–</span>
|
||||
{{end}}
|
||||
</td>
|
||||
<td>
|
||||
{{if .Error}}
|
||||
<span class="validation-badge validation-fail" title="{{.Error}}">Hiba</span>
|
||||
{{else}}
|
||||
<span class="validation-badge validation-ok">OK</span>
|
||||
{{end}}
|
||||
</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
{{else}}
|
||||
{{range .Backup.DumpFiles}}
|
||||
<tr>
|
||||
<td>{{.StackName}}</td>
|
||||
<td><span class="db-type-badge db-type-{{.DBType}}">{{dbTypeLabel .DBType}}</span></td>
|
||||
<td class="mono">{{fmtBytes .Size}}</td>
|
||||
<td class="mono">{{fmtTimeShort .ModTime}}</td>
|
||||
<td>
|
||||
{{if .Validation.Valid}}
|
||||
<span class="validation-badge validation-ok">{{.Validation.TableCount}} tábla</span>
|
||||
{{else if .Validation.Error}}
|
||||
<span class="validation-badge validation-fail" title="{{.Validation.Error}}">Hiba</span>
|
||||
{{else}}
|
||||
<span class="validation-badge validation-na">–</span>
|
||||
{{end}}
|
||||
</td>
|
||||
<td><span class="validation-badge validation-ok">OK</span></td>
|
||||
</tr>
|
||||
{{end}}
|
||||
{{end}}
|
||||
</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">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>
|
||||
|
||||
<!-- Section 4: Unified per-app backup status -->
|
||||
{{if .Backup.AppDataInfo}}
|
||||
<div class="backup-section-card">
|
||||
<h3>Alkalmazások mentési állapota</h3>
|
||||
|
||||
{{if .NoUserDataBackupWarning}}
|
||||
<div class="alert alert-error" style="margin-bottom:1.5rem">
|
||||
<strong>Felhasználói adatokról nincs biztonsági mentés.</strong><br>
|
||||
A szerveren tárolt fotók, dokumentumok és egyéb fájlok jelenleg csak egy példányban léteznek.
|
||||
Külső meghajtó csatlakoztatásával biztonsági másolat készíthető a 3-2-1 szabály szerint.
|
||||
<a href="/settings" style="color:inherit;text-decoration:underline">Meghajtó beállítása →</a>
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
{{range .AppBackupRows}}
|
||||
<div class="app-backup-row" data-status="{{.Status}}">
|
||||
<div class="app-backup-row-header" onclick="toggleBackupDetail(this)">
|
||||
<span class="status-dot status-{{.Status}}" title="{{.StatusText}}"></span>
|
||||
<span class="app-backup-row-name">{{.DisplayName}}</span>
|
||||
<div class="app-backup-row-meta">
|
||||
{{if .DriveDisconnected}}
|
||||
<span class="tag tag-warn">Meghajtó leválasztva</span>
|
||||
{{else if .HasHDDData}}
|
||||
{{if .StorageLabel}}<span class="meta-badge meta-badge-storage">{{.StorageLabel}}</span>{{end}}
|
||||
<span class="mono app-backup-size" style="font-size:.8rem">{{.HDDSizeHuman}}</span>
|
||||
{{else if .HasVolumeData}}
|
||||
<span class="meta-badge">Konfig{{if .HasDB}} + DB{{end}} + Adatok</span>
|
||||
{{else}}
|
||||
<span class="meta-badge">Konfig{{if .HasDB}} + DB{{end}}</span>
|
||||
{{end}}
|
||||
</div>
|
||||
<span class="expand-icon">▶</span>
|
||||
</div>
|
||||
<div class="app-backup-row-detail" style="display:none">
|
||||
<div class="backup-layers">
|
||||
<!-- Tier 1: Nightly backup (mandatory, same drive) -->
|
||||
<div class="backup-layer-row">
|
||||
<span class="tier-label">1. mentés</span>
|
||||
<span class="layer-badge">Auto</span>
|
||||
<span class="tier-location">helyi</span>
|
||||
{{if .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>
|
||||
{{end}}
|
||||
<span class="tier-contents">{{.BackupContents}}</span>
|
||||
{{if and .HasDB (eq .Tier1DBStatus "error")}}
|
||||
<span class="text-error" style="font-size:.8rem"><svg class="ico ico-sm"><use href="#i-triangle-alert"/></svg> DB dump hiba</span>
|
||||
{{end}}
|
||||
</div>
|
||||
<!-- Tier 2: Cross-drive backup (opt-in, different device) -->
|
||||
<div class="backup-layer-row">
|
||||
<span class="tier-label">2. mentés</span>
|
||||
{{if .Tier2UserDisabled}}
|
||||
<span class="layer-unconfigured">2. mentés kikapcsolva</span>
|
||||
<div class="layer-actions">
|
||||
<a href="/stacks/{{.StackName}}/backup" class="btn btn-xs btn-outline">Beállítás</a>
|
||||
</div>
|
||||
{{else if and .Tier2Configured .Tier2DestDisconnected}}
|
||||
<span class="layer-method" style="opacity:.6">rsync</span>
|
||||
<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ó: {{timeAgoStr .Tier2LastRun}}</span>
|
||||
{{end}}
|
||||
<span class="tier-contents" style="opacity:.6">{{.BackupContents}}</span>
|
||||
<div class="layer-actions">
|
||||
<a href="/stacks/{{.StackName}}/backup" class="btn btn-xs btn-outline">Beállítás</a>
|
||||
</div>
|
||||
{{else if and .Tier2Configured .Tier2DestInactive}}
|
||||
<span class="layer-method" style="opacity:.6">rsync</span>
|
||||
<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ó: {{timeAgoStr .Tier2LastRun}}</span>
|
||||
{{end}}
|
||||
<span class="tier-contents" style="opacity:.6">{{.BackupContents}}</span>
|
||||
<div class="layer-actions">
|
||||
<a href="/stacks/{{.StackName}}/backup" class="btn btn-xs btn-outline">Beállítás</a>
|
||||
</div>
|
||||
{{else if .Tier2Configured}}
|
||||
<span class="layer-method">rsync</span>
|
||||
<span class="layer-dest">→ {{.Tier2Dest}}</span>
|
||||
<span class="layer-schedule">{{.Tier2Schedule}}</span>
|
||||
{{if .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>
|
||||
</span>
|
||||
{{end}}
|
||||
{{if .Tier2SizeHuman}}<span class="tier-size">{{.Tier2SizeHuman}}</span>{{end}}
|
||||
<span class="tier-contents">{{.BackupContents}}</span>
|
||||
<span class="tier-browsable" title="A mentés böngészhető fájlrendszerben"><svg class="ico ico-sm"><use href="#i-file-text"/></svg></span>
|
||||
<div class="layer-actions">
|
||||
{{if .Tier2LastRun}}
|
||||
<form method="POST" action="/backup/tier2/restore" style="display:inline">{{$.CSRFField}}
|
||||
<input type="hidden" name="stack_name" value="{{.StackName}}">
|
||||
<button type="submit" class="btn btn-xs btn-outline" data-confirm="Visszaállítja a hiányzó fájlokat a másodlagos másolatból? A meglévő fájlok NEM módosulnak és NEM törlődnek. Az alkalmazás a művelet idejére leáll. Legutóbbi másolat: {{.Tier2LastRun}}">Fájlok visszaállítása</button>
|
||||
</form>
|
||||
{{end}}
|
||||
<a href="/stacks/{{.StackName}}/backup" class="btn btn-xs btn-outline">Beállítás</a>
|
||||
</div>
|
||||
{{else}}
|
||||
<span class="layer-auto-ok"><svg class="ico ico-sm"><use href="#i-check"/></svg> 1. mentés auto</span>
|
||||
<span class="layer-unconfigured"><svg class="ico ico-sm"><use href="#i-triangle-alert"/></svg> Nincs 2. (off-drive) másolat</span>
|
||||
{{if .Tier2LastError}}
|
||||
<span class="layer-reason" style="opacity:.85" title="A 2. mentés automatikus — külön beállítás nem kell">{{.Tier2LastError}}</span>
|
||||
{{end}}
|
||||
<div class="layer-actions">
|
||||
<a href="/stacks/{{.StackName}}/backup" class="btn btn-xs btn-outline">Beállítás</a>
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
<!-- 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">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">
|
||||
{{range .Warnings}}
|
||||
<div class="backup-layer-warning">{{.}}</div>
|
||||
{{end}}
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
<!-- Section 7: Restore -->
|
||||
{{if .Backup.AppDataInfo}}
|
||||
<div class="backup-section-card">
|
||||
<h3>Visszaállítás</h3>
|
||||
<div class="restore-section">
|
||||
<div class="restore-form-row">
|
||||
<label class="restore-label">Alkalmazás:</label>
|
||||
<select id="restore-app" class="restore-select" onchange="onRestoreAppChange()">
|
||||
<option value="">— Válasszon —</option>
|
||||
{{range .Backup.AppDataInfo}}
|
||||
<option value="{{.StackName}}" data-has-hdd="{{.HasHDDData}}" data-has-db="{{.HasDBDump}}" data-has-volumes="{{.HasVolumeData}}">{{.DisplayName}}</option>
|
||||
{{end}}
|
||||
</select>
|
||||
</div>
|
||||
<div class="restore-form-row">
|
||||
<label class="restore-label">Pillanatkép:</label>
|
||||
<select id="restore-snapshot" class="restore-select" onchange="onRestoreConfirmChange()">
|
||||
<option value="">— Válasszon alkalmazást —</option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="restore-type-info" class="restore-info" style="display:none;margin-bottom:0.5rem">
|
||||
</div>
|
||||
<div id="restore-no-snapshots" class="restore-warning" style="display:none;">
|
||||
Még nincs mentés felhasználói adattal.
|
||||
</div>
|
||||
<div class="restore-warning">
|
||||
<svg class="ico ico-sm"><use href="#i-triangle-alert"/></svg> A visszaállítás felülírja az alkalmazás jelenlegi adatait a kiválasztott mentés állapotával.
|
||||
Az alkalmazás a folyamat során automatikusan leáll és újraindul.
|
||||
</div>
|
||||
<div class="restore-confirm">
|
||||
<label>
|
||||
<input type="checkbox" id="restore-confirm-cb" onchange="onRestoreConfirmChange()">
|
||||
Megértettem, visszaállítás indítása.
|
||||
</label>
|
||||
</div>
|
||||
<div class="restore-actions">
|
||||
<button type="button" class="btn btn-sm btn-danger" id="restore-btn" disabled onclick="submitRestore()">Visszaállítás indítása</button>
|
||||
</div>
|
||||
<div style="margin-top: 1rem; text-align: center; border-top: 1px solid var(--line); padding-top: 1rem;">
|
||||
<a href="/import" class="btn btn-sm btn-outline">Importálás mentett csomagból (.fab)</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
{{end}}
|
||||
|
||||
<script>
|
||||
// Part B: restore-progress banner. Polls the async restore op-status every 3s. Shows a neutral
|
||||
// "in progress" while running (including on a fresh page load mid-op), success on completion, and the
|
||||
// error state ONLY on failure. Stops polling when idle after a terminal result was shown.
|
||||
(function(){
|
||||
var banner = document.getElementById('restore-banner');
|
||||
if (!banner) return;
|
||||
var sawRunning = false;
|
||||
function opLabel(op){ return op === 'tier2-restore' ? 'Fájl-visszaállítás'
|
||||
: op === 'offbox-restore' ? 'Távoli visszaállítás' : 'Visszaállítás'; }
|
||||
function render(st){
|
||||
if (st.running) {
|
||||
sawRunning = true;
|
||||
banner.className = 'flash';
|
||||
banner.style.display = 'block';
|
||||
banner.textContent = opLabel(st.op) + ' folyamatban' + (st.stack ? ': ' + st.stack : '') + '…';
|
||||
return;
|
||||
}
|
||||
if (st.last && sawRunning) {
|
||||
banner.style.display = 'block';
|
||||
if (st.last.ok) {
|
||||
banner.className = 'flash flash-success';
|
||||
banner.textContent = st.last.message || (opLabel(st.last.op) + ' kész.');
|
||||
} else {
|
||||
banner.className = 'flash flash-error';
|
||||
banner.textContent = st.last.message || (opLabel(st.last.op) + ' sikertelen.');
|
||||
}
|
||||
}
|
||||
}
|
||||
function poll(){
|
||||
fetch('/api/backup/restore-status', {headers: {'Accept':'application/json'}})
|
||||
.then(function(r){ return r.json(); })
|
||||
.then(function(j){ if (j && j.data) render(j.data); })
|
||||
.catch(function(){});
|
||||
}
|
||||
poll();
|
||||
setInterval(poll, 3000);
|
||||
})();
|
||||
function toggleBackupDetail(header) {
|
||||
var detail = header.nextElementSibling;
|
||||
var icon = header.querySelector('.expand-icon');
|
||||
if (detail.style.display === 'none') {
|
||||
detail.style.display = 'block';
|
||||
icon.textContent = '▼';
|
||||
} else {
|
||||
detail.style.display = 'none';
|
||||
icon.textContent = '▶';
|
||||
}
|
||||
}
|
||||
|
||||
function triggerBackupFromPage() {
|
||||
const btn = document.getElementById('backup-page-btn');
|
||||
btn.disabled = true;
|
||||
btn.textContent = 'Mentés indítása...';
|
||||
fetch('/api/backup/run', { method: 'POST', headers: csrfHeaders() })
|
||||
.then(r => r.json())
|
||||
.then(data => {
|
||||
if (data.ok) {
|
||||
btn.textContent = 'Mentés folyamatban...';
|
||||
btn.classList.add('loading');
|
||||
startBackupPolling();
|
||||
} else {
|
||||
btn.textContent = data.error || 'Hiba';
|
||||
setTimeout(() => { btn.textContent = 'Mentés most'; btn.disabled = false; }, 3000);
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
btn.textContent = 'Hiba';
|
||||
setTimeout(() => { btn.textContent = 'Mentés most'; btn.disabled = false; }, 3000);
|
||||
});
|
||||
}
|
||||
|
||||
function startBackupPolling() {
|
||||
const poll = setInterval(() => {
|
||||
fetch('/api/backup/status')
|
||||
.then(r => r.json())
|
||||
.then(data => {
|
||||
if (data.ok && data.data && !data.data.running) {
|
||||
clearInterval(poll);
|
||||
window.location.reload();
|
||||
}
|
||||
})
|
||||
.catch(() => {});
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
// Whole-guest (appliance) backup — manual trigger via the quiesce loop (controller-owned quiesce:
|
||||
// stop stacks → agent vzdump → resume). Returns immediately; we poll /api/guest-backup/status.
|
||||
function triggerGuestBackup() {
|
||||
@@ -710,142 +195,6 @@ function pollGuestBackup(out, btn) {
|
||||
if (tries > 180) { clearInterval(iv); btn.disabled = false; } // ~15 min cap at 5s polls
|
||||
}, 5000);
|
||||
}
|
||||
|
||||
// Restore section
|
||||
var huDays = ['vasárnap', 'hétfő', 'kedd', 'szerda', 'csütörtök', 'péntek', 'szombat'];
|
||||
function formatSnapshot(s) {
|
||||
var t = new Date(s.time);
|
||||
var pad = function(n) { return n < 10 ? '0' + n : '' + n; };
|
||||
var label = t.getFullYear() + '-' + pad(t.getMonth()+1) + '-' + pad(t.getDate()) +
|
||||
' ' + huDays[t.getDay()] + ' ' + pad(t.getHours()) + ':' + pad(t.getMinutes()) +
|
||||
' (' + s.short_id + ')';
|
||||
var tierLabel = s.tier === 2 ? '2. szint' : '1. szint';
|
||||
if (s.drive_label) {
|
||||
label += ' — ' + tierLabel + ', ' + s.drive_label;
|
||||
} else {
|
||||
label += ' — ' + tierLabel;
|
||||
}
|
||||
return label;
|
||||
}
|
||||
|
||||
function onRestoreAppChange() {
|
||||
var sel = document.getElementById('restore-app');
|
||||
var appName = sel.value;
|
||||
var snapSel = document.getElementById('restore-snapshot');
|
||||
var noSnaps = document.getElementById('restore-no-snapshots');
|
||||
var typeInfo = document.getElementById('restore-type-info');
|
||||
|
||||
document.getElementById('restore-confirm-cb').checked = false;
|
||||
document.getElementById('restore-btn').disabled = true;
|
||||
noSnaps.style.display = 'none';
|
||||
typeInfo.style.display = 'none';
|
||||
|
||||
if (!appName) {
|
||||
snapSel.innerHTML = '<option value="">— Válasszon alkalmazást —</option>';
|
||||
return;
|
||||
}
|
||||
|
||||
// Determine restore type from data attributes
|
||||
var opt = sel.options[sel.selectedIndex];
|
||||
var hasHDD = opt.getAttribute('data-has-hdd') === 'true';
|
||||
var hasDB = opt.getAttribute('data-has-db') === 'true';
|
||||
var hasVolumes = opt.getAttribute('data-has-volumes') === 'true';
|
||||
|
||||
if (hasHDD || hasVolumes) {
|
||||
typeInfo.innerHTML = 'Teljes visszaállítás: adatbázis + konfiguráció + felhasználói adatok a kiválasztott pillanatképből.';
|
||||
typeInfo.className = 'restore-info';
|
||||
} else if (hasDB) {
|
||||
typeInfo.innerHTML = 'Adatbázis és konfiguráció visszaállítása — az alkalmazásnak nincs külön felhasználói adata.';
|
||||
typeInfo.className = 'restore-info restore-info-partial';
|
||||
} else {
|
||||
typeInfo.innerHTML = 'Csak konfiguráció visszaállítása (compose fájlok, beállítások).';
|
||||
typeInfo.className = 'restore-info restore-info-partial';
|
||||
}
|
||||
typeInfo.style.display = 'block';
|
||||
|
||||
snapSel.innerHTML = '<option value="">— Betöltés... —</option>';
|
||||
|
||||
fetch('/api/backup/snapshots?stack=' + encodeURIComponent(appName))
|
||||
.then(function(r) { return r.json(); })
|
||||
.then(function(data) {
|
||||
snapSel.innerHTML = '<option value="">— Válasszon —</option>';
|
||||
if (data.ok && data.data && data.data.length > 0) {
|
||||
// Group by tier
|
||||
var tier1 = data.data.filter(function(s) { return s.tier !== 2; });
|
||||
var tier2 = data.data.filter(function(s) { return s.tier === 2; });
|
||||
|
||||
if (tier1.length > 0) {
|
||||
var grp1 = document.createElement('optgroup');
|
||||
grp1.label = '1. szint — Helyi mentés (ajánlott)';
|
||||
tier1.forEach(function(s) {
|
||||
var o = document.createElement('option');
|
||||
o.value = s.short_id;
|
||||
o.textContent = formatSnapshot(s);
|
||||
grp1.appendChild(o);
|
||||
});
|
||||
snapSel.appendChild(grp1);
|
||||
}
|
||||
if (tier2.length > 0) {
|
||||
var grp2 = document.createElement('optgroup');
|
||||
grp2.label = '2. szint — Másodlagos másolat';
|
||||
tier2.forEach(function(s) {
|
||||
var o = document.createElement('option');
|
||||
o.value = s.short_id;
|
||||
o.textContent = formatSnapshot(s);
|
||||
grp2.appendChild(o);
|
||||
});
|
||||
snapSel.appendChild(grp2);
|
||||
}
|
||||
} else {
|
||||
snapSel.innerHTML = '<option value="">— Nincs elérhető mentés —</option>';
|
||||
noSnaps.style.display = 'block';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function onRestoreConfirmChange() {
|
||||
var cb = document.getElementById('restore-confirm-cb');
|
||||
var app = document.getElementById('restore-app').value;
|
||||
var snap = document.getElementById('restore-snapshot').value;
|
||||
document.getElementById('restore-btn').disabled = !(cb.checked && app && snap);
|
||||
}
|
||||
|
||||
function submitRestore() {
|
||||
var app = document.getElementById('restore-app').value;
|
||||
var snap = document.getElementById('restore-snapshot').value;
|
||||
if (!app || !snap) return;
|
||||
|
||||
var btn = document.getElementById('restore-btn');
|
||||
btn.disabled = true;
|
||||
btn.textContent = 'Visszaállítás folyamatban...';
|
||||
|
||||
var form = document.createElement('form');
|
||||
form.method = 'POST';
|
||||
form.action = '/backup/restore';
|
||||
|
||||
var fc = document.createElement('input');
|
||||
fc.type = 'hidden'; fc.name = '_csrf';
|
||||
fc.value = (document.querySelector('meta[name="csrf-token"]') || {}).content || '';
|
||||
form.appendChild(fc);
|
||||
|
||||
var f1 = document.createElement('input');
|
||||
f1.type = 'hidden'; f1.name = 'stack_name'; f1.value = app;
|
||||
form.appendChild(f1);
|
||||
|
||||
var f2 = document.createElement('input');
|
||||
f2.type = 'hidden'; f2.name = 'snapshot_id'; f2.value = snap;
|
||||
form.appendChild(f2);
|
||||
|
||||
document.body.appendChild(form);
|
||||
form.submit();
|
||||
}
|
||||
|
||||
// Auto-poll if backup is already running on page load
|
||||
{{if .Backup}}{{if .Backup.Running}}
|
||||
startBackupPolling();
|
||||
{{end}}{{end}}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
{{template "layout_end" .}}
|
||||
|
||||
@@ -0,0 +1,348 @@
|
||||
{{define "backups_apps"}}
|
||||
{{template "layout_start" .}}
|
||||
|
||||
<div class="page-header">
|
||||
<h2>Biztonsági mentés — Alkalmazások</h2>
|
||||
<span class="domain-badge">{{.Domain}}</span>
|
||||
</div>
|
||||
|
||||
{{template "backups_flash" .}}
|
||||
{{template "restore_banner" .}}
|
||||
|
||||
{{if not .Backup}}
|
||||
{{template "backups_empty" .}}
|
||||
{{else}}
|
||||
|
||||
<h3 class="backup-tier-divider">Alkalmazás-mentések (adatbázis + konfiguráció)</h3>
|
||||
<p class="form-hint" style="margin:-0.25rem 0 1rem">Az egyes alkalmazások részletes, granulált mentése — adatbázis-kiírások, beállítások és alkalmazás-fájlok. A fenti teljes mentéstől függetlenül, alkalmazásonként visszaállítható.</p>
|
||||
|
||||
<!-- Section 2: Schedule -->
|
||||
<div class="schedule-card">
|
||||
<h3>Ütemezés</h3>
|
||||
<div class="schedule-rows">
|
||||
<div class="schedule-row">
|
||||
<span class="schedule-task">Adatbázis mentés</span>
|
||||
<span class="schedule-time">{{.Backup.DBDumpSchedule}}</span>
|
||||
<span class="schedule-next">Következő: {{nextRunLabel .Backup.NextDBDump}}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="schedule-summary">
|
||||
{{if .Backup.LastDBDump}}
|
||||
<div class="schedule-summary-row">
|
||||
<span>Utolsó adatbázis mentés:</span>
|
||||
<span class="schedule-summary-value">{{fmtTime .Backup.LastDBDump.LastRun}} ({{timeAgo .Backup.LastDBDump.LastRun}})</span>
|
||||
</div>
|
||||
{{else}}
|
||||
<div class="schedule-summary-row">
|
||||
<span>Utolsó adatbázis mentés:</span>
|
||||
<span class="schedule-summary-value relative-time">Még nem futott</span>
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
<div class="schedule-actions">
|
||||
<button class="btn btn-sm btn-primary" onclick="triggerBackupFromPage()" id="backup-page-btn"
|
||||
{{if .Backup.Running}}disabled{{end}}>
|
||||
{{if .Backup.Running}}Mentés folyamatban...{{else}}Mentés most{{end}}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Section 3: Databases -->
|
||||
<div class="backup-section-card">
|
||||
<h3>Adatbázisok</h3>
|
||||
{{if or .Backup.DumpFiles .Backup.DiscoveredDBs}}
|
||||
<div class="backup-table-wrap">
|
||||
<table class="db-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Alkalmazás</th>
|
||||
<th>Típus</th>
|
||||
<th>Méret</th>
|
||||
<th>Utolsó</th>
|
||||
<th>Érvényesítés</th>
|
||||
<th>Állapot</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{if .Backup.LastDBDump}}
|
||||
{{range .Backup.LastDBDump.Results}}
|
||||
<tr>
|
||||
<td>{{.DB.StackName}}</td>
|
||||
<td><span class="db-type-badge db-type-{{.DB.DBType}}">{{dbTypeLabel .DB.DBType}}</span></td>
|
||||
<td class="mono">{{if .Error}}–{{else}}{{fmtBytes .Size}}{{end}}</td>
|
||||
<td class="mono">{{if .Error}}–{{else}}{{fmtTimeShort $.Backup.LastDBDump.LastRun}}{{end}}</td>
|
||||
<td>
|
||||
{{if .Error}}
|
||||
<span class="validation-badge validation-na">–</span>
|
||||
{{else if .Validation.Valid}}
|
||||
<span class="validation-badge validation-ok">{{.Validation.TableCount}} tábla</span>
|
||||
{{else if .Validation.Error}}
|
||||
<span class="validation-badge validation-fail" title="{{.Validation.Error}}">Hiba</span>
|
||||
{{else}}
|
||||
<span class="validation-badge validation-na" title="Az érvényesítés nem futott le">–</span>
|
||||
{{end}}
|
||||
</td>
|
||||
<td>
|
||||
{{if .Error}}
|
||||
<span class="validation-badge validation-fail" title="{{.Error}}">Hiba</span>
|
||||
{{else}}
|
||||
<span class="validation-badge validation-ok">OK</span>
|
||||
{{end}}
|
||||
</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
{{else}}
|
||||
{{range .Backup.DumpFiles}}
|
||||
<tr>
|
||||
<td>{{.StackName}}</td>
|
||||
<td><span class="db-type-badge db-type-{{.DBType}}">{{dbTypeLabel .DBType}}</span></td>
|
||||
<td class="mono">{{fmtBytes .Size}}</td>
|
||||
<td class="mono">{{fmtTimeShort .ModTime}}</td>
|
||||
<td>
|
||||
{{if .Validation.Valid}}
|
||||
<span class="validation-badge validation-ok">{{.Validation.TableCount}} tábla</span>
|
||||
{{else if .Validation.Error}}
|
||||
<span class="validation-badge validation-fail" title="{{.Validation.Error}}">Hiba</span>
|
||||
{{else}}
|
||||
<span class="validation-badge validation-na">–</span>
|
||||
{{end}}
|
||||
</td>
|
||||
<td><span class="validation-badge validation-ok">OK</span></td>
|
||||
</tr>
|
||||
{{end}}
|
||||
{{end}}
|
||||
</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">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>
|
||||
|
||||
<!-- Section 4: Unified per-app backup status -->
|
||||
{{if .Backup.AppDataInfo}}
|
||||
<div class="backup-section-card">
|
||||
<h3>Alkalmazások mentési állapota</h3>
|
||||
|
||||
{{if .NoUserDataBackupWarning}}
|
||||
<div class="alert alert-error" style="margin-bottom:1.5rem">
|
||||
<strong>Felhasználói adatokról nincs biztonsági mentés.</strong><br>
|
||||
A szerveren tárolt fotók, dokumentumok és egyéb fájlok jelenleg csak egy példányban léteznek.
|
||||
Külső meghajtó csatlakoztatásával biztonsági másolat készíthető a 3-2-1 szabály szerint.
|
||||
<a href="/settings" style="color:inherit;text-decoration:underline">Meghajtó beállítása →</a>
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
{{range .AppBackupRows}}
|
||||
<div class="app-backup-row" data-status="{{.Status}}">
|
||||
<div class="app-backup-row-header" onclick="toggleBackupDetail(this)">
|
||||
<span class="status-dot status-{{.Status}}" title="{{.StatusText}}"></span>
|
||||
<span class="app-backup-row-name">{{.DisplayName}}</span>
|
||||
<div class="app-backup-row-meta">
|
||||
{{if .DriveDisconnected}}
|
||||
<span class="tag tag-warn">Meghajtó leválasztva</span>
|
||||
{{else if .HasHDDData}}
|
||||
{{if .StorageLabel}}<span class="meta-badge meta-badge-storage">{{.StorageLabel}}</span>{{end}}
|
||||
<span class="mono app-backup-size" style="font-size:.8rem">{{.HDDSizeHuman}}</span>
|
||||
{{else if .HasVolumeData}}
|
||||
<span class="meta-badge">Konfig{{if .HasDB}} + DB{{end}} + Adatok</span>
|
||||
{{else}}
|
||||
<span class="meta-badge">Konfig{{if .HasDB}} + DB{{end}}</span>
|
||||
{{end}}
|
||||
</div>
|
||||
<span class="expand-icon">▶</span>
|
||||
</div>
|
||||
<div class="app-backup-row-detail" style="display:none">
|
||||
<div class="backup-layers">
|
||||
<!-- Tier 1: Nightly backup (mandatory, same drive) -->
|
||||
<div class="backup-layer-row">
|
||||
<span class="tier-label">1. mentés</span>
|
||||
<span class="layer-badge">Auto</span>
|
||||
<span class="tier-location">helyi</span>
|
||||
{{if .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>
|
||||
{{end}}
|
||||
<span class="tier-contents">{{.BackupContents}}</span>
|
||||
{{if and .HasDB (eq .Tier1DBStatus "error")}}
|
||||
<span class="text-error" style="font-size:.8rem"><svg class="ico ico-sm"><use href="#i-triangle-alert"/></svg> DB dump hiba</span>
|
||||
{{end}}
|
||||
</div>
|
||||
<!-- Tier 2: Cross-drive backup (opt-in, different device) -->
|
||||
<div class="backup-layer-row">
|
||||
<span class="tier-label">2. mentés</span>
|
||||
{{if .Tier2UserDisabled}}
|
||||
<span class="layer-unconfigured">2. mentés kikapcsolva</span>
|
||||
<div class="layer-actions">
|
||||
<a href="/stacks/{{.StackName}}/backup" class="btn btn-xs btn-outline">Beállítás</a>
|
||||
</div>
|
||||
{{else if and .Tier2Configured .Tier2DestDisconnected}}
|
||||
<span class="layer-method" style="opacity:.6">rsync</span>
|
||||
<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ó: {{timeAgoStr .Tier2LastRun}}</span>
|
||||
{{end}}
|
||||
<span class="tier-contents" style="opacity:.6">{{.BackupContents}}</span>
|
||||
<div class="layer-actions">
|
||||
<a href="/stacks/{{.StackName}}/backup" class="btn btn-xs btn-outline">Beállítás</a>
|
||||
</div>
|
||||
{{else if and .Tier2Configured .Tier2DestInactive}}
|
||||
<span class="layer-method" style="opacity:.6">rsync</span>
|
||||
<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ó: {{timeAgoStr .Tier2LastRun}}</span>
|
||||
{{end}}
|
||||
<span class="tier-contents" style="opacity:.6">{{.BackupContents}}</span>
|
||||
<div class="layer-actions">
|
||||
<a href="/stacks/{{.StackName}}/backup" class="btn btn-xs btn-outline">Beállítás</a>
|
||||
</div>
|
||||
{{else if .Tier2Configured}}
|
||||
<span class="layer-method">rsync</span>
|
||||
<span class="layer-dest">→ {{.Tier2Dest}}</span>
|
||||
<span class="layer-schedule">{{.Tier2Schedule}}</span>
|
||||
{{if .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>
|
||||
</span>
|
||||
{{end}}
|
||||
{{if .Tier2SizeHuman}}<span class="tier-size">{{.Tier2SizeHuman}}</span>{{end}}
|
||||
<span class="tier-contents">{{.BackupContents}}</span>
|
||||
<span class="tier-browsable" title="A mentés böngészhető fájlrendszerben"><svg class="ico ico-sm"><use href="#i-file-text"/></svg></span>
|
||||
<div class="layer-actions">
|
||||
{{if .Tier2LastRun}}
|
||||
<form method="POST" action="/backup/tier2/restore" style="display:inline">{{$.CSRFField}}
|
||||
<input type="hidden" name="stack_name" value="{{.StackName}}">
|
||||
<button type="submit" class="btn btn-xs btn-outline" data-confirm="Visszaállítja a hiányzó fájlokat a másodlagos másolatból? A meglévő fájlok NEM módosulnak és NEM törlődnek. Az alkalmazás a művelet idejére leáll. Legutóbbi másolat: {{.Tier2LastRun}}">Fájlok visszaállítása</button>
|
||||
</form>
|
||||
{{end}}
|
||||
<a href="/stacks/{{.StackName}}/backup" class="btn btn-xs btn-outline">Beállítás</a>
|
||||
</div>
|
||||
{{else}}
|
||||
<span class="layer-auto-ok"><svg class="ico ico-sm"><use href="#i-check"/></svg> 1. mentés auto</span>
|
||||
<span class="layer-unconfigured"><svg class="ico ico-sm"><use href="#i-triangle-alert"/></svg> Nincs 2. (off-drive) másolat</span>
|
||||
{{if .Tier2LastError}}
|
||||
<span class="layer-reason" style="opacity:.85" title="A 2. mentés automatikus — külön beállítás nem kell">{{.Tier2LastError}}</span>
|
||||
{{end}}
|
||||
<div class="layer-actions">
|
||||
<a href="/stacks/{{.StackName}}/backup" class="btn btn-xs btn-outline">Beállítás</a>
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
<!-- 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">Kikapcsolva</span>
|
||||
<span class="tier-contents">Ez az alkalmazás nincs kijelölve távoli mentésre</span>
|
||||
<div class="layer-actions">
|
||||
<a href="/backups/remote#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="/backups/remote#offbox-section" class="btn btn-xs btn-outline">Beállítás</a>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
{{if .Warnings}}
|
||||
<div class="layer-warnings">
|
||||
{{range .Warnings}}
|
||||
<div class="backup-layer-warning">{{.}}</div>
|
||||
{{end}}
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
{{end}}
|
||||
|
||||
<script>
|
||||
{{template "restore_banner_js"}}
|
||||
function toggleBackupDetail(header) {
|
||||
var detail = header.nextElementSibling;
|
||||
var icon = header.querySelector('.expand-icon');
|
||||
if (detail.style.display === 'none') {
|
||||
detail.style.display = 'block';
|
||||
icon.textContent = '▼';
|
||||
} else {
|
||||
detail.style.display = 'none';
|
||||
icon.textContent = '▶';
|
||||
}
|
||||
}
|
||||
|
||||
function triggerBackupFromPage() {
|
||||
const btn = document.getElementById('backup-page-btn');
|
||||
btn.disabled = true;
|
||||
btn.textContent = 'Mentés indítása...';
|
||||
fetch('/api/backup/run', { method: 'POST', headers: csrfHeaders() })
|
||||
.then(r => r.json())
|
||||
.then(data => {
|
||||
if (data.ok) {
|
||||
btn.textContent = 'Mentés folyamatban...';
|
||||
btn.classList.add('loading');
|
||||
startBackupPolling();
|
||||
} else {
|
||||
btn.textContent = data.error || 'Hiba';
|
||||
setTimeout(() => { btn.textContent = 'Mentés most'; btn.disabled = false; }, 3000);
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
btn.textContent = 'Hiba';
|
||||
setTimeout(() => { btn.textContent = 'Mentés most'; btn.disabled = false; }, 3000);
|
||||
});
|
||||
}
|
||||
|
||||
function startBackupPolling() {
|
||||
const poll = setInterval(() => {
|
||||
fetch('/api/backup/status')
|
||||
.then(r => r.json())
|
||||
.then(data => {
|
||||
if (data.ok && data.data && !data.data.running) {
|
||||
clearInterval(poll);
|
||||
window.location.reload();
|
||||
}
|
||||
})
|
||||
.catch(() => {});
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
// Auto-poll if backup is already running on page load
|
||||
{{if .Backup}}{{if .Backup.Running}}
|
||||
startBackupPolling();
|
||||
{{end}}{{end}}
|
||||
</script>
|
||||
|
||||
{{template "layout_end" .}}
|
||||
{{end}}
|
||||
@@ -0,0 +1,107 @@
|
||||
{{define "backups_remote"}}
|
||||
{{template "layout_start" .}}
|
||||
|
||||
<div class="page-header">
|
||||
<h2>Biztonsági mentés — Távoli mentés</h2>
|
||||
<span class="domain-badge">{{.Domain}}</span>
|
||||
</div>
|
||||
|
||||
{{template "backups_flash" .}}
|
||||
|
||||
{{if not .Backup}}
|
||||
{{template "backups_empty" .}}
|
||||
{{else}}
|
||||
|
||||
<!-- Off-box (NAS) backup — Part B: encrypted restic repo over SFTP (the off-site 3-2-1 leg). -->
|
||||
<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">
|
||||
<div class="stat-card {{if eq .Offbox.LastStatus "error"}}stat-warn{{end}}">
|
||||
<div class="stat-value" style="font-size:1.15rem">{{if eq .Offbox.LastStatus "ok"}}✓ Rendben{{else if eq .Offbox.LastStatus "error"}}✗ Hiba{{else if eq .Offbox.LastStatus "running"}}Fut…{{else}}–{{end}}</div>
|
||||
<div class="stat-label">Utolsó távoli mentés{{if .Offbox.LastRun}}<br><span class="relative-time">{{timeAgoStr .Offbox.LastRun}}</span>{{end}}</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-value" style="font-size:1.15rem">{{if .Offbox.RepoSizeHuman}}{{.Offbox.RepoSizeHuman}}{{else}}–{{end}}</div>
|
||||
<div class="stat-label">Tároló méret · {{.Offbox.SnapshotCount}} pillanatkép</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-value" style="font-size:1.05rem">{{if .Offbox.Enabled}}{{.Offbox.User}}@{{.Offbox.Host}}{{else}}Kikapcsolva{{end}}</div>
|
||||
<div class="stat-label">{{if .Offbox.Enabled}}{{.Offbox.RepoPath}}{{else}}A távoli mentés ki van kapcsolva{{end}}</div>
|
||||
</div>
|
||||
</div>
|
||||
{{if and .Offbox.Enabled (gt .Offbox.QuotaGB 0)}}
|
||||
<!-- SLICE 4: soft-quota usage bar (shared model; quota_gb from the hub descriptor). -->
|
||||
<div id="offbox-quota-bar" style="max-width:560px;margin:.5rem 0">
|
||||
<div class="stat-label" style="margin-bottom:.25rem">Tárhelykeret: {{if .Offbox.RepoSizeHuman}}{{.Offbox.RepoSizeHuman}}{{else}}0{{end}} / {{.Offbox.QuotaGB}} GB ({{.OffboxQuotaPct}}%)</div>
|
||||
<div style="background:var(--border,#334);border-radius:4px;height:8px;overflow:hidden">
|
||||
<div style="height:8px;border-radius:4px;width:{{.OffboxQuotaPct}}%;background:{{if ge .OffboxQuotaPct 100}}var(--crit,#e5484d){{else if ge .OffboxQuotaPct 80}}var(--warn,#f5a524){{else}}var(--ok,#30a46c){{end}}"></div>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
{{if .Offbox.LastError}}<p class="form-hint" style="color:var(--crit)">Utolsó hiba: {{.Offbox.LastError}}</p>{{end}}
|
||||
{{if .Offbox.LastWarning}}<p class="form-hint" style="color:var(--warn)">{{.Offbox.LastWarning}}</p>{{end}}
|
||||
{{if and .OffboxConfigured (ne .Offbox.EscrowState "escrowed")}}
|
||||
<div class="card" style="border-left:3px solid var(--warn);margin:.75rem 0;padding:.75rem 1rem">
|
||||
<p class="form-hint" style="color:var(--warn);margin:0 0 .5rem">A távoli mentés a kulcs letétbe helyezésére vár — a mentés addig nem fut (így nem keletkezik visszaállíthatatlan másolat). Futtasd a letéti szertartást, majd erősítsd meg.</p>
|
||||
<form method="POST" action="/backup/offbox/confirm-escrow" style="display:inline">{{.CSRFField}}
|
||||
<button type="submit" class="btn btn-sm">Letét megerősítése</button>
|
||||
</form>
|
||||
</div>
|
||||
{{end}}
|
||||
{{if .OffboxConfigured}}
|
||||
<div class="schedule-actions" style="margin-top:1rem">
|
||||
<form method="POST" action="/backup/offbox/run" style="display:inline">{{.CSRFField}}
|
||||
<button type="submit" class="btn btn-sm btn-primary">Távoli mentés most</button>
|
||||
</form>
|
||||
</div>
|
||||
<h4 style="margin-top:1.25rem">Mely alkalmazások mentődnek a távoli tárolóra?</h4>
|
||||
{{if and .OffboxApps (eq .Offbox.EscrowState "escrowed") (eq .OffboxToggledCount 0)}}
|
||||
<p class="form-hint">Nincs távoli mentésre jelölt alkalmazás — jelölj ki legalább egyet.</p>
|
||||
{{end}}
|
||||
{{if .OffboxApps}}
|
||||
<div class="storage-paths-list">
|
||||
{{range .OffboxApps}}
|
||||
<div class="storage-path-item">
|
||||
<div class="storage-path-header">
|
||||
<div class="storage-path-info"><span class="storage-path-label">{{.DisplayName}}</span></div>
|
||||
<div class="storage-path-actions">
|
||||
<form method="POST" action="/backup/offbox/toggle" style="display:inline">{{$.CSRFField}}
|
||||
<input type="hidden" name="app" value="{{.Name}}">
|
||||
<input type="hidden" name="enabled" value="{{if .Enabled}}false{{else}}true{{end}}">
|
||||
<button type="submit" class="btn btn-xs {{if .Enabled}}btn-outline{{else}}btn-primary{{end}}">{{if .Enabled}}Távoli mentés kikapcsolása{{else}}Távoli mentés bekapcsolása{{end}}</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
{{else}}<p class="form-hint">Nincs telepített alkalmazás.</p>{{end}}
|
||||
{{end}}
|
||||
{{else}}
|
||||
<p class="form-hint">Még nincs beállítva távoli mentési cél.</p>
|
||||
{{end}}
|
||||
|
||||
<details style="margin-top:1rem">
|
||||
<summary class="btn btn-xs btn-primary" style="cursor:pointer;display:inline-block">Távoli mentési cél beállítása</summary>
|
||||
<form method="POST" action="/backup/offbox/config" style="margin-top:.75rem;padding:1rem;border:1px solid var(--border,#ddd);border-radius:6px;max-width:560px">{{.CSRFField}}
|
||||
<div class="form-row"><label>Cél címe (IP vagy hosztnév — NAS vagy SFTP-kiszolgáló)</label><input type="text" name="host" class="form-input" value="{{if .Offbox}}{{.Offbox.Host}}{{end}}" placeholder="pl. 192.168.0.10"></div>
|
||||
<div class="form-row"><label>SSH port</label><input type="number" name="port" class="form-input" value="{{if .Offbox}}{{.Offbox.Port}}{{else}}22{{end}}"></div>
|
||||
<div class="form-row"><label>Felhasználó</label><input type="text" name="user" class="form-input" value="{{if .Offbox}}{{.Offbox.User}}{{end}}" placeholder="pl. felhom"></div>
|
||||
<div class="form-row"><label>Tároló útvonala a célgépen</label><input type="text" name="repo_path" class="form-input" value="{{if .Offbox}}{{.Offbox.RepoPath}}{{end}}" placeholder="pl. /volume1/felhom-backup/repo"></div>
|
||||
<div class="form-row"><label><input type="checkbox" name="enabled" {{if .Offbox}}{{if .Offbox.Enabled}}checked{{end}}{{else}}checked{{end}}> Napi automatikus távoli mentés engedélyezve</label></div>
|
||||
<div class="form-row"><label>SSH privát kulcs {{if .OffboxConfigured}}(üresen hagyva változatlan){{end}}</label>
|
||||
<textarea name="ssh_key" class="form-input" rows="4" autocomplete="off" placeholder="-----BEGIN OPENSSH PRIVATE KEY-----"></textarea>
|
||||
<span class="form-hint">A kulcsot 0600-as fájlba írjuk; sosem naplózzuk és nem tároljuk a beállításokban.</span></div>
|
||||
<div class="form-row"><label>A célgép ismert-host sora (known_hosts) {{if .OffboxConfigured}}(üresen hagyva változatlan){{end}}</label>
|
||||
<textarea name="known_hosts" class="form-input" rows="2" autocomplete="off" placeholder="nas.local ssh-ed25519 AAAA…"></textarea>
|
||||
<span class="form-hint">A host-kulcs rögzítése (no blind TOFU). Lekérdezhető: <span class="mono">ssh-keyscan -p <port> <host></span></span></div>
|
||||
<button type="submit" class="btn btn-sm btn-primary" style="margin-top:.5rem">Mentés</button>
|
||||
</form>
|
||||
</details>
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
{{template "layout_end" .}}
|
||||
{{end}}
|
||||
@@ -0,0 +1,227 @@
|
||||
{{define "backups_restore"}}
|
||||
{{template "layout_start" .}}
|
||||
|
||||
<div class="page-header">
|
||||
<h2>Biztonsági mentés — Visszaállítás</h2>
|
||||
<span class="domain-badge">{{.Domain}}</span>
|
||||
</div>
|
||||
|
||||
{{template "backups_flash" .}}
|
||||
{{template "restore_banner" .}}
|
||||
|
||||
{{if not .Backup}}
|
||||
{{template "backups_empty" .}}
|
||||
{{else}}
|
||||
|
||||
<!-- Section 7: Restore -->
|
||||
{{if .Backup.AppDataInfo}}
|
||||
<div class="backup-section-card">
|
||||
<h3>Visszaállítás</h3>
|
||||
<div class="restore-section">
|
||||
<div class="restore-form-row">
|
||||
<label class="restore-label">Alkalmazás:</label>
|
||||
<select id="restore-app" class="restore-select" onchange="onRestoreAppChange()">
|
||||
<option value="">— Válasszon —</option>
|
||||
{{range .Backup.AppDataInfo}}
|
||||
<option value="{{.StackName}}" data-has-hdd="{{.HasHDDData}}" data-has-db="{{.HasDBDump}}" data-has-volumes="{{.HasVolumeData}}">{{.DisplayName}}</option>
|
||||
{{end}}
|
||||
</select>
|
||||
</div>
|
||||
<div class="restore-form-row">
|
||||
<label class="restore-label">Pillanatkép:</label>
|
||||
<select id="restore-snapshot" class="restore-select" onchange="onRestoreConfirmChange()">
|
||||
<option value="">— Válasszon alkalmazást —</option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="restore-type-info" class="restore-info" style="display:none;margin-bottom:0.5rem">
|
||||
</div>
|
||||
<div id="restore-no-snapshots" class="restore-warning" style="display:none;">
|
||||
Még nincs mentés felhasználói adattal.
|
||||
</div>
|
||||
<div class="restore-warning">
|
||||
<svg class="ico ico-sm"><use href="#i-triangle-alert"/></svg> A visszaállítás felülírja az alkalmazás jelenlegi adatait a kiválasztott mentés állapotával.
|
||||
Az alkalmazás a folyamat során automatikusan leáll és újraindul.
|
||||
</div>
|
||||
<div class="restore-confirm">
|
||||
<label>
|
||||
<input type="checkbox" id="restore-confirm-cb" onchange="onRestoreConfirmChange()">
|
||||
Megértettem, visszaállítás indítása.
|
||||
</label>
|
||||
</div>
|
||||
<div class="restore-actions">
|
||||
<button type="button" class="btn btn-sm btn-danger" id="restore-btn" disabled onclick="submitRestore()">Visszaállítás indítása</button>
|
||||
</div>
|
||||
<div style="margin-top: 1rem; text-align: center; border-top: 1px solid var(--line); padding-top: 1rem;">
|
||||
<a href="/import" class="btn btn-sm btn-outline">Importálás mentett csomagból (.fab)</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
<!-- Ellenőrző visszaállítás a távoli (3. mentés) tárolóból — the per-app restore-to-verify
|
||||
forms moved here from the Távoli mentés toggle list (v0.124.0 IA split). Display list =
|
||||
the offbox-toggled apps; the action itself is unchanged. -->
|
||||
{{if .OffboxConfigured}}
|
||||
<div class="backup-section-card">
|
||||
<h3>Ellenőrző visszaállítás a távoli tárolóból</h3>
|
||||
<p class="form-hint" style="margin:-0.25rem 0 1rem">A távoli mentésre kijelölt alkalmazások legutóbbi pillanatképe egy külön ellenőrző mappába állítható vissza — a meglévő adatok nem változnak.</p>
|
||||
{{if .OffboxToggledCount}}
|
||||
<div class="storage-paths-list">
|
||||
{{range .OffboxApps}}
|
||||
{{if .Enabled}}
|
||||
<div class="storage-path-item">
|
||||
<div class="storage-path-header">
|
||||
<div class="storage-path-info"><span class="storage-path-label">{{.DisplayName}}</span></div>
|
||||
<div class="storage-path-actions">
|
||||
<form method="POST" action="/backup/offbox/restore" style="display:inline">{{$.CSRFField}}
|
||||
<input type="hidden" name="app" value="{{.Name}}">
|
||||
<button type="submit" class="btn btn-xs btn-outline" data-confirm="Visszaállítja a(z) {{.DisplayName}} adatait a távoli tárolóról egy ellenőrző mappába? A meglévő adatok NEM íródnak felül.">Visszaállítás (ellenőrzéshez)</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
{{end}}
|
||||
</div>
|
||||
{{else}}
|
||||
<p class="form-hint">Nincs távoli mentésre jelölt alkalmazás — a kijelölés a <a href="/backups/remote">Távoli mentés</a> oldalon történik.</p>
|
||||
{{end}}
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
{{end}}
|
||||
|
||||
<script>
|
||||
{{template "restore_banner_js"}}
|
||||
// Restore section
|
||||
var huDays = ['vasárnap', 'hétfő', 'kedd', 'szerda', 'csütörtök', 'péntek', 'szombat'];
|
||||
function formatSnapshot(s) {
|
||||
var t = new Date(s.time);
|
||||
var pad = function(n) { return n < 10 ? '0' + n : '' + n; };
|
||||
var label = t.getFullYear() + '-' + pad(t.getMonth()+1) + '-' + pad(t.getDate()) +
|
||||
' ' + huDays[t.getDay()] + ' ' + pad(t.getHours()) + ':' + pad(t.getMinutes()) +
|
||||
' (' + s.short_id + ')';
|
||||
var tierLabel = s.tier === 2 ? '2. szint' : '1. szint';
|
||||
if (s.drive_label) {
|
||||
label += ' — ' + tierLabel + ', ' + s.drive_label;
|
||||
} else {
|
||||
label += ' — ' + tierLabel;
|
||||
}
|
||||
return label;
|
||||
}
|
||||
|
||||
function onRestoreAppChange() {
|
||||
var sel = document.getElementById('restore-app');
|
||||
var appName = sel.value;
|
||||
var snapSel = document.getElementById('restore-snapshot');
|
||||
var noSnaps = document.getElementById('restore-no-snapshots');
|
||||
var typeInfo = document.getElementById('restore-type-info');
|
||||
|
||||
document.getElementById('restore-confirm-cb').checked = false;
|
||||
document.getElementById('restore-btn').disabled = true;
|
||||
noSnaps.style.display = 'none';
|
||||
typeInfo.style.display = 'none';
|
||||
|
||||
if (!appName) {
|
||||
snapSel.innerHTML = '<option value="">— Válasszon alkalmazást —</option>';
|
||||
return;
|
||||
}
|
||||
|
||||
// Determine restore type from data attributes
|
||||
var opt = sel.options[sel.selectedIndex];
|
||||
var hasHDD = opt.getAttribute('data-has-hdd') === 'true';
|
||||
var hasDB = opt.getAttribute('data-has-db') === 'true';
|
||||
var hasVolumes = opt.getAttribute('data-has-volumes') === 'true';
|
||||
|
||||
if (hasHDD || hasVolumes) {
|
||||
typeInfo.innerHTML = 'Teljes visszaállítás: adatbázis + konfiguráció + felhasználói adatok a kiválasztott pillanatképből.';
|
||||
typeInfo.className = 'restore-info';
|
||||
} else if (hasDB) {
|
||||
typeInfo.innerHTML = 'Adatbázis és konfiguráció visszaállítása — az alkalmazásnak nincs külön felhasználói adata.';
|
||||
typeInfo.className = 'restore-info restore-info-partial';
|
||||
} else {
|
||||
typeInfo.innerHTML = 'Csak konfiguráció visszaállítása (compose fájlok, beállítások).';
|
||||
typeInfo.className = 'restore-info restore-info-partial';
|
||||
}
|
||||
typeInfo.style.display = 'block';
|
||||
|
||||
snapSel.innerHTML = '<option value="">— Betöltés... —</option>';
|
||||
|
||||
fetch('/api/backup/snapshots?stack=' + encodeURIComponent(appName))
|
||||
.then(function(r) { return r.json(); })
|
||||
.then(function(data) {
|
||||
snapSel.innerHTML = '<option value="">— Válasszon —</option>';
|
||||
if (data.ok && data.data && data.data.length > 0) {
|
||||
// Group by tier
|
||||
var tier1 = data.data.filter(function(s) { return s.tier !== 2; });
|
||||
var tier2 = data.data.filter(function(s) { return s.tier === 2; });
|
||||
|
||||
if (tier1.length > 0) {
|
||||
var grp1 = document.createElement('optgroup');
|
||||
grp1.label = '1. szint — Helyi mentés (ajánlott)';
|
||||
tier1.forEach(function(s) {
|
||||
var o = document.createElement('option');
|
||||
o.value = s.short_id;
|
||||
o.textContent = formatSnapshot(s);
|
||||
grp1.appendChild(o);
|
||||
});
|
||||
snapSel.appendChild(grp1);
|
||||
}
|
||||
if (tier2.length > 0) {
|
||||
var grp2 = document.createElement('optgroup');
|
||||
grp2.label = '2. szint — Másodlagos másolat';
|
||||
tier2.forEach(function(s) {
|
||||
var o = document.createElement('option');
|
||||
o.value = s.short_id;
|
||||
o.textContent = formatSnapshot(s);
|
||||
grp2.appendChild(o);
|
||||
});
|
||||
snapSel.appendChild(grp2);
|
||||
}
|
||||
} else {
|
||||
snapSel.innerHTML = '<option value="">— Nincs elérhető mentés —</option>';
|
||||
noSnaps.style.display = 'block';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function onRestoreConfirmChange() {
|
||||
var cb = document.getElementById('restore-confirm-cb');
|
||||
var app = document.getElementById('restore-app').value;
|
||||
var snap = document.getElementById('restore-snapshot').value;
|
||||
document.getElementById('restore-btn').disabled = !(cb.checked && app && snap);
|
||||
}
|
||||
|
||||
function submitRestore() {
|
||||
var app = document.getElementById('restore-app').value;
|
||||
var snap = document.getElementById('restore-snapshot').value;
|
||||
if (!app || !snap) return;
|
||||
|
||||
var btn = document.getElementById('restore-btn');
|
||||
btn.disabled = true;
|
||||
btn.textContent = 'Visszaállítás folyamatban...';
|
||||
|
||||
var form = document.createElement('form');
|
||||
form.method = 'POST';
|
||||
form.action = '/backup/restore';
|
||||
|
||||
var fc = document.createElement('input');
|
||||
fc.type = 'hidden'; fc.name = '_csrf';
|
||||
fc.value = (document.querySelector('meta[name="csrf-token"]') || {}).content || '';
|
||||
form.appendChild(fc);
|
||||
|
||||
var f1 = document.createElement('input');
|
||||
f1.type = 'hidden'; f1.name = 'stack_name'; f1.value = app;
|
||||
form.appendChild(f1);
|
||||
|
||||
var f2 = document.createElement('input');
|
||||
f2.type = 'hidden'; f2.name = 'snapshot_id'; f2.value = snap;
|
||||
form.appendChild(f2);
|
||||
|
||||
document.body.appendChild(form);
|
||||
form.submit();
|
||||
}
|
||||
</script>
|
||||
|
||||
{{template "layout_end" .}}
|
||||
{{end}}
|
||||
@@ -0,0 +1,63 @@
|
||||
{{define "backups_flash"}}
|
||||
{{if .Backup}}{{if .Backup.FlashSuccess}}
|
||||
<div class="flash flash-success">{{.Backup.FlashSuccess}}</div>
|
||||
{{end}}{{end}}
|
||||
{{if .Backup}}{{if .Backup.FlashError}}
|
||||
<div class="flash flash-error">{{.Backup.FlashError}}</div>
|
||||
{{end}}{{end}}
|
||||
{{end}}
|
||||
|
||||
{{define "backups_empty"}}
|
||||
<div class="backup-empty-state">
|
||||
<div class="backup-empty-icon">🛡</div>
|
||||
<h3>Biztonsági mentés nincs beállítva</h3>
|
||||
<p>A biztonsági mentés funkció nem aktív.<br>
|
||||
Kérjük, vegye fel a kapcsolatot a Felhom csapattal a beállításhoz.</p>
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
{{define "restore_banner"}}
|
||||
<!-- Part B: async restore progress banner — polls /api/backup/restore-status; neutral while running,
|
||||
red only on failure (exception-color principle). Hidden until a restore op is seen. -->
|
||||
<div id="restore-banner" class="flash" style="display:none"></div>
|
||||
{{end}}
|
||||
|
||||
{{define "restore_banner_js"}}
|
||||
// Part B: restore-progress banner. Polls the async restore op-status every 3s. Shows a neutral
|
||||
// "in progress" while running (including on a fresh page load mid-op), success on completion, and the
|
||||
// error state ONLY on failure. Stops polling when idle after a terminal result was shown.
|
||||
(function(){
|
||||
var banner = document.getElementById('restore-banner');
|
||||
if (!banner) return;
|
||||
var sawRunning = false;
|
||||
function opLabel(op){ return op === 'tier2-restore' ? 'Fájl-visszaállítás'
|
||||
: op === 'offbox-restore' ? 'Távoli visszaállítás' : 'Visszaállítás'; }
|
||||
function render(st){
|
||||
if (st.running) {
|
||||
sawRunning = true;
|
||||
banner.className = 'flash';
|
||||
banner.style.display = 'block';
|
||||
banner.textContent = opLabel(st.op) + ' folyamatban' + (st.stack ? ': ' + st.stack : '') + '…';
|
||||
return;
|
||||
}
|
||||
if (st.last && sawRunning) {
|
||||
banner.style.display = 'block';
|
||||
if (st.last.ok) {
|
||||
banner.className = 'flash flash-success';
|
||||
banner.textContent = st.last.message || (opLabel(st.last.op) + ' kész.');
|
||||
} else {
|
||||
banner.className = 'flash flash-error';
|
||||
banner.textContent = st.last.message || (opLabel(st.last.op) + ' sikertelen.');
|
||||
}
|
||||
}
|
||||
}
|
||||
function poll(){
|
||||
fetch('/api/backup/restore-status', {headers: {'Accept':'application/json'}})
|
||||
.then(function(r){ return r.json(); })
|
||||
.then(function(j){ if (j && j.data) render(j.data); })
|
||||
.catch(function(){});
|
||||
}
|
||||
poll();
|
||||
setInterval(poll, 3000);
|
||||
})();
|
||||
{{end}}
|
||||
@@ -56,7 +56,14 @@
|
||||
<li><a href="/storage/network" class="{{if eq .Page "storage-network"}}active{{end}}">Hálózati tárhely</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="/backups" class="{{if eq .Page "backups"}}active{{end}}"><svg class="ico"><use href="#i-shield"/></svg>Biztonsági mentés</a></li>
|
||||
<li><a href="/backups" class="{{if or (eq .Page "backups") (eq .Page "backups-remote") (eq .Page "backups-apps") (eq .Page "backups-restore")}}active{{end}}"><svg class="ico"><use href="#i-shield"/></svg>Biztonsági mentés</a>
|
||||
<ul class="nav-links nav-links-sub nav-links-nested">
|
||||
<li><a href="/backups" class="{{if eq .Page "backups"}}active{{end}}">Áttekintés</a></li>
|
||||
<li><a href="/backups/remote" class="{{if eq .Page "backups-remote"}}active{{end}}">Távoli mentés</a></li>
|
||||
<li><a href="/backups/apps" class="{{if eq .Page "backups-apps"}}active{{end}}">Alkalmazások</a></li>
|
||||
<li><a href="/backups/restore" class="{{if eq .Page "backups-restore"}}active{{end}}">Visszaállítás</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="/monitoring" class="{{if eq .Page "monitoring"}}active{{end}}"><svg class="ico"><use href="#i-cpu"/></svg>Rendszermonitor</a></li>
|
||||
<li><a href="/debug" class="{{if eq .Page "debug"}}active{{end}}"><svg class="ico"><use href="#i-wrench"/></svg>Debug</a></li>
|
||||
</ul>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
<div class="page-header">
|
||||
<h2>2. mentés beállítása — {{.DisplayName}}</h2>
|
||||
<a href="/backups" class="btn btn-outline btn-sm">← Vissza a mentésekhez</a>
|
||||
<a href="/backups/apps" class="btn btn-outline btn-sm">← Vissza a mentésekhez</a>
|
||||
</div>
|
||||
|
||||
{{if .Flash}}<div class="monitoring-banner monitoring-banner-green">{{.Flash}}</div>{{end}}
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Backups IA-split move check (v0.124.0, one-shot) — the split MOVED the v0.123.0 sections,
|
||||
it did not rewrite them: every moved block from the pre-split backups.html (commit df7ad37)
|
||||
must appear, whitespace-normalized, on EXACTLY its mapped page. Allowed divergences are encoded
|
||||
explicitly (the tier-3 anchor retarget; the restore-to-verify form's relocation).
|
||||
|
||||
Run from controller/: python scripts/backups_split_move_check.py
|
||||
"""
|
||||
import io, os, re, subprocess, sys
|
||||
|
||||
BASELINE = "df7ad37"
|
||||
OLD_PATH = "controller/internal/web/templates/backups.html"
|
||||
TPL = os.path.join("internal", "web", "templates")
|
||||
|
||||
# (name, 1-indexed start, end inclusive, target template file, normalizer applied to the NEW page)
|
||||
BLOCKS = [
|
||||
("storage-overview", 32, 77, "backups.html", None),
|
||||
("whole-guest", 79, 124, "backups.html", None),
|
||||
("stat-cards", 227, 271, "backups.html", None),
|
||||
("offbox-pre", 127, 186, "backups_remote.html", None),
|
||||
("offbox-post", 193, 221, "backups_remote.html", None),
|
||||
("apps-divider", 224, 225, "backups_apps.html", None),
|
||||
("schedule", 273, 302, "backups_apps.html", None),
|
||||
("databases", 304, 376, "backups_apps.html", None),
|
||||
# the tier-3 action anchors were retargeted cross-page — normalize them back before comparing
|
||||
("per-app-rows", 378, 541, "backups_apps.html",
|
||||
lambda s: s.replace('href="/backups/remote#offbox-section"', 'href="#offbox-section"')),
|
||||
("restore-panel", 543, 586, "backups_restore.html", None),
|
||||
("offbox-verify-form", 188, 191, "backups_restore.html", None),
|
||||
("banner-js", 591, 627, "backups_shared.html", None),
|
||||
("apps-js", 628, 674, "backups_apps.html", None),
|
||||
("guest-js", 676, 712, "backups.html", None),
|
||||
("restore-js", 714, 841, "backups_restore.html", None),
|
||||
]
|
||||
|
||||
PAGES = ["backups.html", "backups_remote.html", "backups_apps.html", "backups_restore.html",
|
||||
"backups_shared.html"]
|
||||
|
||||
|
||||
def norm(s):
|
||||
return re.sub(r"\s+", " ", s).strip()
|
||||
|
||||
|
||||
def main():
|
||||
old = subprocess.run(["git", "show", BASELINE + ":" + OLD_PATH],
|
||||
capture_output=True, text=True, encoding="utf-8")
|
||||
if old.returncode != 0:
|
||||
print("cannot read baseline %s:%s — %s" % (BASELINE, OLD_PATH, old.stderr.strip()))
|
||||
sys.exit(2)
|
||||
old_lines = old.stdout.split("\n")
|
||||
|
||||
pages = {}
|
||||
for fn in PAGES:
|
||||
pages[fn] = io.open(os.path.join(TPL, fn), encoding="utf-8").read()
|
||||
|
||||
failed = 0
|
||||
for name, a, b, target, fix in BLOCKS:
|
||||
block = norm("\n".join(old_lines[a - 1:b]))
|
||||
hits = []
|
||||
for fn in PAGES:
|
||||
content = pages[fn]
|
||||
if fix:
|
||||
content = fix(content)
|
||||
if block in norm(content):
|
||||
hits.append(fn)
|
||||
if hits != [target]:
|
||||
failed += 1
|
||||
print("MOVED-BLOCK MISMATCH %-18s (old L%d-%d): expected [%s], found %s"
|
||||
% (name, a, b, target, hits))
|
||||
if failed:
|
||||
print("MOVE CHECK FAILED: %d block(s) rewritten, duplicated or lost" % failed)
|
||||
sys.exit(1)
|
||||
print("move check OK — all %d v0.123.0 blocks moved verbatim to their mapped page" % len(BLOCKS))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user