PostgreSQL backup tool with Point-In-Time-Recovery and restore verification
TypeScript backupbackupsdatabasedatabase-backupdevopsdockergolangkubernetesmariadbmongodbmysqlpgpostgrespostgresqls3self-hostedsystem-administrationtoolsweb-ui
FIX (restores): Fix order of temp files closing that causes flaky tests
Rostislav Dugin0acd205f43fa
diff --git a/backend/internal/features/backups/backups/usecases/postgresql/create_backup_uc.go b/backend/internal/features/backups/backups/usecases/postgresql/create_backup_uc.goindex 383f3b25..bfb7e94c 100644--- a/backend/internal/features/backups/backups/usecases/postgresql/create_backup_uc.go+++ b/backend/internal/features/backups/backups/usecases/postgresql/create_backup_uc.go@@ -255,10 +255,10 @@ func (uc *CreatePostgresqlBackupUsecase) streamToStorage(copyResultCh <- err}()- // Wait for the dump and copy to finish- waitErr := cmd.Wait()+ // Wait for the copy to finish first, then the dump processcopyErr := <-copyResultChbytesWritten := <-bytesWrittenCh+ waitErr := cmd.Wait()// Check for shutdown before finalizingif config.IsShouldShutdown() {diff --git a/backend/internal/features/storages/models/local/model.go b/backend/internal/features/storages/models/local/model.goindex 8efd98c4..d84b8048 100644--- a/backend/internal/features/storages/models/local/model.go+++ b/backend/internal/features/storages/models/local/model.go@@ -62,6 +62,12 @@ func (l *LocalStorage) SaveFile(logger *slog.Logger, fileID uuid.UUID, file io.Rreturn fmt.Errorf("failed to sync temp file: %w", err)}+ // Close the temp file explicitly before moving it (required on Windows)+ if err = tempFile.Close(); err != nil {+ logger.Error("Failed to close temp file", "fileId", fileID.String(), "error", err)+ return fmt.Errorf("failed to close temp file: %w", err)+ }+finalPath := filepath.Join(config.GetEnv().DataFolder, fileID.String())logger.Debug("Moving file from temp to final location",