diff --git a/internal/backup/backup.go b/internal/backup/backup.go index 148313f..173fbb3 100644 --- a/internal/backup/backup.go +++ b/internal/backup/backup.go @@ -142,15 +142,16 @@ func Create(cfg *core.Configuration, reason string) (nowTime time.Time, returned return nowTime, fmt.Errorf("could not write into Swift: %w", err) } - err = lo.WriteManifest(ctx, hdr.ToOpts()) + // wait for pg_dump to finish before finalizing the object in Swift + // (otherwise we might end up storing incomplete or broken backups) + err = <-errChan if err != nil { - return nowTime, fmt.Errorf("could not finalize upload into Swift: %w", err) + return nowTime, fmt.Errorf("could not run pg_dump: %w", err) } - // wait for pg_dump to finish - err = <-errChan + err = lo.WriteManifest(ctx, hdr.ToOpts()) if err != nil { - return nowTime, fmt.Errorf("could not run pg_dump: %w", err) + return nowTime, fmt.Errorf("could not finalize upload into Swift: %w", err) } }