diff --git a/dbbackup b/dbbackup index 89a21dd..e3bc232 100755 Binary files a/dbbackup and b/dbbackup differ diff --git a/dbbackup_linux_amd64 b/dbbackup_linux_amd64 index 89a21dd..e3bc232 100755 Binary files a/dbbackup_linux_amd64 and b/dbbackup_linux_amd64 differ diff --git a/internal/restore/engine.go b/internal/restore/engine.go index 0089aba..893fb97 100644 --- a/internal/restore/engine.go +++ b/internal/restore/engine.go @@ -339,6 +339,7 @@ func (e *Engine) RestoreCluster(ctx context.Context, archivePath string) error { successCount := 0 failCount := 0 + var failedDBs []string for i, entry := range entries { if entry.IsDir() { @@ -354,11 +355,13 @@ func (e *Engine) RestoreCluster(ctx context.Context, archivePath string) error { // Create database first if it doesn't exist if err := e.ensureDatabaseExists(ctx, dbName); err != nil { e.log.Warn("Could not ensure database exists", "name", dbName, "error", err) - // Continue anyway - pg_restore can create it + // Continue anyway - pg_restore might handle it } - if err := e.restorePostgreSQLDump(ctx, dumpFile, dbName, false, false); err != nil { + // Restore with clean flag to drop existing objects + if err := e.restorePostgreSQLDump(ctx, dumpFile, dbName, false, true); err != nil { e.log.Error("Failed to restore database", "name", dbName, "error", err) + failedDBs = append(failedDBs, fmt.Sprintf("%s: %v", dbName, err)) failCount++ continue } @@ -367,9 +370,10 @@ func (e *Engine) RestoreCluster(ctx context.Context, archivePath string) error { } if failCount > 0 { + failedList := strings.Join(failedDBs, "; ") e.progress.Fail(fmt.Sprintf("Cluster restore completed with errors: %d succeeded, %d failed", successCount, failCount)) operation.Complete(fmt.Sprintf("Partial restore: %d succeeded, %d failed", successCount, failCount)) - return fmt.Errorf("cluster restore completed with %d failures", failCount) + return fmt.Errorf("cluster restore completed with %d failures: %s", failCount, failedList) } e.progress.Complete(fmt.Sprintf("Cluster restored successfully: %d databases", successCount))