Files
felhom-controller/controller/internal/appbackup/paths.go
T
admin 63484a0bd4 v0.51.0: offsite-backup UI (felhom-pbs DR) + Model-A double-nest fix
- Backups page: whole-guest backup shown as real DR — target label "Biztonsági szerver –
  külön hardver (PBS)"; app-data "Távoli mentés" card now reflects the PBS offsite tier
  (guestBackupView.Offsite) instead of "nincs beállítva".
- Model-A double-nest fix: appbackup path helpers take a felhom-data NAMESPACE ROOT (no
  internal felhom-data join); backup.Manager.namespaceRoot/AppNamespaceRoot resolve
  HDD-vs-systemDataPath provenance so a drive-resident app's backups land single-nested
  (<drive>/backups/... on the guest = <drive>/felhom-data/backups/... on the host) instead
  of .../felhom-data/felhom-data/.... Writes, deletion (GetStackBackupData/RemoveStack/
  ProtectedHDDPaths), wipe-warning scan, and export updated coherently; legacy double-nest
  dirs kept protected. New appbackup test asserts no doubled segment.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-12 20:26:52 +02:00

50 lines
2.4 KiB
Go

// Package appbackup holds the self-contained app-data backup primitives:
// database dump and Docker-volume archive discovery/execution, plus the
// keep-side storage path helpers. It depends only on stable abstractions
// (the StackDataProvider interface) and has no dependency on the restic,
// cross-drive, or drive-mount code in the backup package.
package appbackup
import "path/filepath"
// FelhomDataDir is the namespace directory on storage drives for all felhom-managed data.
const FelhomDataDir = "felhom-data"
// NamespaceRoot resolves the felhom-data namespace ROOT for a drive path. All the path helpers
// below take this namespace root (the directory that directly contains backups/ and appdata/),
// NOT a bare drive path — they do not append felhom-data themselves.
//
// Model A (slice 10): the host agent binds <drive>/felhom-data onto the guest mountpoint, so an
// enrolled user-data drive's IN-GUEST mount already IS the namespace root (and its basename need
// NOT be "felhom-data" — e.g. /mnt/felhom-usb). For such mounts pass inGuestDrive=true → the path
// is returned as-is, so callers no longer double-nest into .../felhom-data/felhom-data/... .
//
// For a bare drive root that still holds a felhom-data SUBDIR — the SSD-only system-data fallback,
// or any legacy host-side layout — pass inGuestDrive=false → the felhom-data segment is appended.
func NamespaceRoot(drivePath string, inGuestDrive bool) string {
if inGuestDrive {
return filepath.Clean(drivePath)
}
return filepath.Join(drivePath, FelhomDataDir)
}
// PrimaryBackupPath returns the root primary backup directory under a felhom-data namespace root.
func PrimaryBackupPath(nsRoot string) string {
return filepath.Join(nsRoot, "backups", "primary")
}
// AppDBDumpPath returns the DB dump directory for an app under a felhom-data namespace root.
func AppDBDumpPath(nsRoot, stackName string) string {
return filepath.Join(nsRoot, "backups", "primary", stackName, "db-dumps")
}
// AppVolumeDumpPath returns the Docker-volume dump-tar directory for an app under a namespace root.
func AppVolumeDumpPath(nsRoot, stackName string) string {
return filepath.Join(nsRoot, "backups", "primary", stackName, "volume-dumps")
}
// AppDataDir returns the app data directory under a felhom-data namespace root.
func AppDataDir(nsRoot, stackName string) string {
return filepath.Join(nsRoot, "appdata", stackName)
}