From b40359c6abd0e69c6b759a11f6e92ba67f832f45 Mon Sep 17 00:00:00 2001 From: Bekir Pehlivan Date: Tue, 5 Mar 2024 12:09:30 +0300 Subject: [PATCH] Changed CopyObject with ComposeObject for multipart --- backup/minio.go | 6 +++--- backup/mysql.go | 18 ++++++------------ 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/backup/minio.go b/backup/minio.go index d393d12..d5b9958 100755 --- a/backup/minio.go +++ b/backup/minio.go @@ -72,7 +72,7 @@ func newMinioClient(endpoint, accessKey, secretKey string, secure, insecureSkipV return &c, nil } -func uploadFileToMinio(minioClient *MinioClient, rotation config.Rotation, db string, src string, bucketName string, dst string, minio_dst string) error { +func uploadFileToMinio(minioClient *MinioClient, rotation config.Rotation, db string, src string, bucketName string, dst string, minioDst string) error { src = strings.TrimSuffix(src, "/") _, err := os.Open(src) if err != nil { @@ -93,9 +93,9 @@ func uploadFileToMinio(minioClient *MinioClient, rotation config.Rotation, db st name = name + "." + extension[len(extension)-1] dest := minio.CopyDestOptions{ Bucket: bucketName, - Object: minio_dst + "/" + name, + Object: minioDst + "/" + name, } - _, err := minioClient.CopyObject(context.Background(), dest, source) + _, err := minioClient.ComposeObject(context.Background(), dest, source) if err != nil { return errors.New("Couldn't create copy for rotation. Error: " + err.Error()) } diff --git a/backup/mysql.go b/backup/mysql.go index eae74b4..4c747fa 100644 --- a/backup/mysql.go +++ b/backup/mysql.go @@ -43,6 +43,7 @@ func dumpMySQLDb(db string, dst string, params config.Params, logger Logger) (st var cmd *exec.Cmd var cmd2 *exec.Cmd var stderr bytes.Buffer + output := make([]byte, 100) if encrypted { format = "7zip" @@ -91,7 +92,6 @@ func dumpMySQLDb(db string, dst string, params config.Params, logger Logger) (st logger.Error("Couldn't back up " + db + " - Error: " + err.Error()) return "", "", err } - output := make([]byte, 100) if !encrypted && format == "gzip" { name = name + ".sql.gz" @@ -126,11 +126,6 @@ func dumpMySQLDb(db string, dst string, params config.Params, logger Logger) (st logger.Error("Couldn't compress " + db + " - Error: " + err.Error()) return "", "", err } - n, _ := stderr2.Read(output) - if n > 0 { - logger.Error("Couldn't back up " + db + " - Error: " + string(string(output[:n]))) - return dumpPath, name, errors.New(string(output[:n])) - } } else { name = name + ".sql.7z" dumpPath = dst + "/" + name @@ -148,12 +143,11 @@ func dumpMySQLDb(db string, dst string, params config.Params, logger Logger) (st logger.Error("Couldn't compress " + db + " - Error: " + err.Error() + " - " + stderr.String()) return "", "", err } - n, _ := stderr2.Read(output) - if n > 0 { - logger.Error("Couldn't back up " + db + " - Error: " + string(string(output[:n]))) - return dumpPath, name, errors.New(string(output[:n])) - } } - + n, _ := stderr2.Read(output) + if n > 0 { + logger.Error("Couldn't back up " + db + " - Error: " + string(string(output[:n]))) + return dumpPath, name, errors.New(string(output[:n])) + } return dumpPath, name, nil }