Add delete /tmp directory after backup or restore and update docs

This commit is contained in:
2024-08-11 09:38:31 +02:00
parent 27b9ab5f36
commit a3fc58af96
8 changed files with 59 additions and 10 deletions

View File

@@ -203,6 +203,8 @@ func localBackup(backupFileName string, disableCompression bool, prune bool, bac
if prune {
deleteOldBackup(backupRetention)
}
//Delete temp
deleteTemp()
}
func s3Backup(backupFileName string, disableCompression bool, prune bool, backupRetention int, encrypt bool) {
@@ -216,7 +218,7 @@ func s3Backup(backupFileName string, disableCompression bool, prune bool, backup
encryptBackup(backupFileName)
finalFileName = fmt.Sprintf("%s.%s", backupFileName, "gpg")
}
utils.Info("Uploading backup file to S3 storage...")
utils.Info("Uploading backup archive to remote storage S3 ... ")
utils.Info("Backup name is %s", finalFileName)
err := utils.UploadFileToS3(tmpPath, finalFileName, bucket, s3Path)
if err != nil {
@@ -237,7 +239,9 @@ func s3Backup(backupFileName string, disableCompression bool, prune bool, backup
utils.Fatal("Error deleting old backup from S3: %s ", err)
}
}
utils.Done("Database has been backed up and uploaded to s3 ")
utils.Done("Uploading backup archive to remote storage S3 ... done ")
//Delete temp
deleteTemp()
}
func sshBackup(backupFileName, remotePath string, disableCompression bool, prune bool, backupRetention int, encrypt bool) {
utils.Info("Backup database to Remote server")
@@ -248,7 +252,7 @@ func sshBackup(backupFileName, remotePath string, disableCompression bool, prune
encryptBackup(backupFileName)
finalFileName = fmt.Sprintf("%s.%s", backupFileName, "gpg")
}
utils.Info("Uploading backup file to remote server...")
utils.Info("Uploading backup archive to remote storage ... ")
utils.Info("Backup name is %s", finalFileName)
err := CopyToRemote(finalFileName, remotePath)
if err != nil {
@@ -268,9 +272,10 @@ func sshBackup(backupFileName, remotePath string, disableCompression bool, prune
}
utils.Done("Database has been backed up and uploaded to remote server ")
utils.Done("Uploading backup archive to remote storage ... done ")
//Delete temp
deleteTemp()
}
func encryptBackup(backupFileName string) {
gpgPassphrase := os.Getenv("GPG_PASSPHRASE")
err := Encrypt(filepath.Join(tmpPath, backupFileName), gpgPassphrase)