Skip to content

Commit

Permalink
Changed CopyObject with ComposeObject for multipart
Browse files Browse the repository at this point in the history
  • Loading branch information
LobbyLobster committed Mar 5, 2024
1 parent 32afaa7 commit b40359c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
6 changes: 3 additions & 3 deletions backup/minio.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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())
}
Expand Down
18 changes: 6 additions & 12 deletions backup/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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
}

0 comments on commit b40359c

Please sign in to comment.