Skip to content

PostgreSQL backup tool with Point-In-Time-Recovery and restore verification

FIX (backups): Stream backups to S3 instead of loading backup to RAM in start

Rostislav Dugin3654b777b436
diff --git a/backend/internal/features/storages/models/s3/model.go b/backend/internal/features/storages/models/s3/model.go
index f94e4beb..d94c7042 100644
--- a/backend/internal/features/storages/models/s3/model.go
+++ b/backend/internal/features/storages/models/s3/model.go
@@ -1,7 +1,6 @@
package s3_storage
import (
- "bytes"
"context"
"errors"
"fmt"
@@ -34,19 +33,13 @@ func (s *S3Storage) SaveFile(logger *slog.Logger, fileID uuid.UUID, file io.Read
return err
}
- // Read the entire file into memory
- data, err := io.ReadAll(file)
- if err != nil {
- return fmt.Errorf("failed to read file: %w", err)
- }
-
- // Upload the file using MinIO client
+ // Upload the file using MinIO client with streaming (size = -1 for unknown size)
_, err = client.PutObject(
context.TODO(),
s.S3Bucket,
fileID.String(),
- bytes.NewReader(data),
- int64(len(data)),
+ file,
+ -1,
minio.PutObjectOptions{},
)
if err != nil {