Fix bugs from BUGHUNT.md: restore race conditions, infra backup, DR wiring, docker-setup.sh, restore.html
This commit is contained in:
@@ -76,10 +76,7 @@ func main() {
|
||||
logger.Printf("[INFO] Found infra backup on Hub: %s (%s), %d stacks, synced %s",
|
||||
ib.Domain, ib.CustomerID, len(ib.DeployedStacks), ib.Timestamp)
|
||||
|
||||
// Restore restic passwords
|
||||
restorePasswordsFromHub(ib, cfg, sett, logger)
|
||||
|
||||
// Restore settings.json from Hub backup
|
||||
// Restore settings.json from Hub backup first
|
||||
restoreSettingsFromHub(ib, cfg, logger)
|
||||
|
||||
// Re-load settings (now from restored file)
|
||||
@@ -88,6 +85,9 @@ func main() {
|
||||
logger.Println("[INFO] Settings reloaded after Hub restore")
|
||||
}
|
||||
|
||||
// Restore restic passwords AFTER settings reload so cross-drive password persists
|
||||
restorePasswordsFromHub(ib, cfg, sett, logger)
|
||||
|
||||
// Mount drives using stored disk layout
|
||||
mountCtx, mountCancel := context.WithTimeout(context.Background(), 2*time.Minute)
|
||||
mountedPaths, mountErr := backup.MountDrivesFromLayout(mountCtx, ib.DiskLayout, logger)
|
||||
@@ -122,11 +122,14 @@ func main() {
|
||||
}
|
||||
|
||||
restorePlan = backup.ScanDrivesForBackups(drivePaths, infraStacks, logger)
|
||||
restorePlan.CustomerID = ib.CustomerID
|
||||
restorePlan.Domain = ib.Domain
|
||||
restorePlan.Timestamp = ib.Timestamp
|
||||
|
||||
logger.Printf("[INFO] DR restore plan ready: %d apps to restore", len(restorePlan.Apps))
|
||||
if restorePlan != nil {
|
||||
restorePlan.CustomerID = ib.CustomerID
|
||||
restorePlan.Domain = ib.Domain
|
||||
restorePlan.Timestamp = ib.Timestamp
|
||||
logger.Printf("[INFO] DR restore plan ready: %d apps to restore", len(restorePlan.Apps))
|
||||
} else {
|
||||
logger.Println("[WARN] ScanDrivesForBackups returned nil — no restore plan created")
|
||||
}
|
||||
}
|
||||
} else {
|
||||
logger.Println("[INFO] No infra backup found on Hub for this customer")
|
||||
@@ -589,7 +592,7 @@ func pushInfraBackup(cfg *config.Config, sett *settings.Settings,
|
||||
filepath.Join(cfg.Paths.DataDir, "settings.json"),
|
||||
cfg.Backup.ResticPasswordFile,
|
||||
cfg.Paths.SystemDataPath,
|
||||
sett, stackProv,
|
||||
sett, stackProv, logger,
|
||||
)
|
||||
if err != nil {
|
||||
logger.Printf("[WARN] Failed to build infra backup: %v", err)
|
||||
@@ -621,8 +624,9 @@ func restorePasswordsFromHub(ib *report.InfraBackup, cfg *config.Config,
|
||||
decoded, err := base64.StdEncoding.DecodeString(ib.ResticPassword)
|
||||
if err == nil && len(decoded) > 0 {
|
||||
dir := filepath.Dir(cfg.Backup.ResticPasswordFile)
|
||||
os.MkdirAll(dir, 0700)
|
||||
if err := os.WriteFile(cfg.Backup.ResticPasswordFile, decoded, 0600); err == nil {
|
||||
if err := os.MkdirAll(dir, 0700); err != nil {
|
||||
logger.Printf("[WARN] Failed to create restic password directory %s: %v", dir, err)
|
||||
} else if err := os.WriteFile(cfg.Backup.ResticPasswordFile, decoded, 0600); err == nil {
|
||||
logger.Println("[INFO] Primary restic password restored from Hub")
|
||||
} else {
|
||||
logger.Printf("[WARN] Failed to write restic password file: %v", err)
|
||||
@@ -649,6 +653,10 @@ func restoreSettingsFromHub(ib *report.InfraBackup, cfg *config.Config, logger *
|
||||
logger.Printf("[WARN] Failed to decode settings from Hub: %v", err)
|
||||
return
|
||||
}
|
||||
if err := os.MkdirAll(cfg.Paths.DataDir, 0755); err != nil {
|
||||
logger.Printf("[WARN] Failed to create data directory for settings restore: %v", err)
|
||||
return
|
||||
}
|
||||
settingsPath := filepath.Join(cfg.Paths.DataDir, "settings.json")
|
||||
if err := os.WriteFile(settingsPath, decoded, 0600); err != nil {
|
||||
logger.Printf("[WARN] Failed to write restored settings.json: %v", err)
|
||||
|
||||
Reference in New Issue
Block a user