refactor: extract app-data-backup into internal/appbackup (no behaviour change)
Extract the stateless, keep-side app-data backup primitives out of internal/backup/ into a new self-contained internal/appbackup/ package: - dbdump.go: DB dump discovery/execution (DiscoverDatabases, DumpOne, ...) - appdata.go: StackDataProvider + app-data/volume discovery, HumanizeBytes - paths.go: keep-side path helpers (AppDBDumpPath, AppVolumeDumpPath, AppDataDir) backup/ keeps every name available via type/const aliases + one-line function forwarders (appbackup_bridge.go), so the still-present delete-side code (restic, cross-drive, drive-mount) and the both-side consumers (web/api/report) compile unchanged. The keep-only consumers appexport and storage are rewired to import appbackup directly and no longer import backup. This is the Part-2 prerequisite for the Proxmox port: appbackup has zero references to restic/cross-drive/drive-mount and does not import backup, so the delete-side can later be removed without breaking app-data backup or appexport. Behaviour-preserving: pure move + import/qualifier rewrites, no logic edits. The four Manager methods (RunDBDumps/DumpAppVolumes/DumpAppVolumesSafe share the delete-side mutex/status state; RestoreAppFromTier2 reads the cross-drive mirror) intentionally stay on Manager and delegate to appbackup — for the re-platform step. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -14,7 +14,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"gitea.dooplex.hu/admin/felhom-controller/internal/backup"
|
||||
"gitea.dooplex.hu/admin/felhom-controller/internal/appbackup"
|
||||
)
|
||||
|
||||
// Step tracks one step of an export/import operation.
|
||||
@@ -510,7 +510,7 @@ func (e *Exporter) dumpDatabase(stackName, dbDir string, manifest *Manifest) boo
|
||||
defer cancel()
|
||||
|
||||
e.debugf("discovering databases (looking for stack %s)...", stackName)
|
||||
dbs, err := backup.DiscoverDatabases(ctx, e.logger, e.debug)
|
||||
dbs, err := appbackup.DiscoverDatabases(ctx, e.logger, e.debug)
|
||||
if err != nil {
|
||||
e.logger.Printf("[WARN] Export: DB discovery error: %v", err)
|
||||
return false
|
||||
@@ -520,7 +520,7 @@ func (e *Exporter) dumpDatabase(stackName, dbDir string, manifest *Manifest) boo
|
||||
e.debugf(" db[%d]: stack=%s container=%s type=%s", i, dbs[i].StackName, dbs[i].ContainerName, dbs[i].DBType)
|
||||
}
|
||||
|
||||
var stackDB *backup.DiscoveredDB
|
||||
var stackDB *appbackup.DiscoveredDB
|
||||
for i := range dbs {
|
||||
if dbs[i].StackName == stackName {
|
||||
stackDB = &dbs[i]
|
||||
@@ -534,7 +534,7 @@ func (e *Exporter) dumpDatabase(stackName, dbDir string, manifest *Manifest) boo
|
||||
e.debugf("matched DB: container=%s type=%s", stackDB.ContainerName, stackDB.DBType)
|
||||
|
||||
dumpStart := time.Now()
|
||||
result := backup.DumpOne(ctx, *stackDB, dbDir, e.logger, e.debug)
|
||||
result := appbackup.DumpOne(ctx, *stackDB, dbDir, e.logger, e.debug)
|
||||
if result.Error != nil {
|
||||
e.logger.Printf("[WARN] Export: DB dump failed for %s: %v", stackName, result.Error)
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user