Skip to content

Commit

Permalink
Merge pull request #144 from sapcc/fix-write-order
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperSandro2000 authored Oct 7, 2024
2 parents 4351b4a + a5be3a7 commit 1b62509
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions internal/backup/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down

0 comments on commit 1b62509

Please sign in to comment.