fix: fix multi backup s3 path
This commit is contained in:
@@ -260,6 +260,10 @@ func localBackup(db *dbConfig, config *BackupConfig) {
|
||||
|
||||
func s3Backup(db *dbConfig, config *BackupConfig) {
|
||||
bucket := utils.GetEnvVariable("AWS_S3_BUCKET_NAME", "BUCKET_NAME")
|
||||
s3Path := utils.GetEnvVariable("AWS_S3_PATH", "S3_PATH")
|
||||
if config.remotePath != "" {
|
||||
s3Path = config.remotePath
|
||||
}
|
||||
utils.Info("Backup database to s3 storage")
|
||||
startTime = time.Now().Format(utils.TimeFormat())
|
||||
//Backup database
|
||||
@@ -272,7 +276,7 @@ func s3Backup(db *dbConfig, config *BackupConfig) {
|
||||
utils.Info("Uploading backup archive to remote storage S3 ... ")
|
||||
|
||||
utils.Info("Backup name is %s", finalFileName)
|
||||
err := UploadFileToS3(tmpPath, finalFileName, bucket, config.remotePath)
|
||||
err := UploadFileToS3(tmpPath, finalFileName, bucket, s3Path)
|
||||
if err != nil {
|
||||
utils.Fatal("Error uploading backup archive to S3: %s ", err)
|
||||
|
||||
@@ -292,7 +296,7 @@ func s3Backup(db *dbConfig, config *BackupConfig) {
|
||||
}
|
||||
// Delete old backup
|
||||
if config.prune {
|
||||
err := DeleteOldBackup(bucket, config.remotePath, config.backupRetention)
|
||||
err := DeleteOldBackup(bucket, s3Path, config.backupRetention)
|
||||
if err != nil {
|
||||
utils.Fatal("Error deleting old backup from S3: %s ", err)
|
||||
}
|
||||
@@ -304,7 +308,7 @@ func s3Backup(db *dbConfig, config *BackupConfig) {
|
||||
BackupSize: backupSize,
|
||||
Database: db.dbName,
|
||||
Storage: config.storage,
|
||||
BackupLocation: filepath.Join(config.remotePath, finalFileName),
|
||||
BackupLocation: filepath.Join(s3Path, finalFileName),
|
||||
StartTime: startTime,
|
||||
EndTime: time.Now().Format(utils.TimeFormat()),
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user