Merge pull request #108 from jkaninda/refactor

Refactor
This commit is contained in:
2024-10-03 18:19:12 +02:00
committed by GitHub
2 changed files with 7 additions and 9 deletions

View File

@@ -42,8 +42,6 @@ func scheduledMode(db *dbConfig, config *BackupConfig) {
utils.Info("Backup cron expression: %s", config.cronExpression)
utils.Info("Storage type %s ", config.storage)
//Test database connexion
testDatabaseConnection(db)
//Test backup
utils.Info("Testing backup configurations...")
BackupTask(db, config)
@@ -75,11 +73,11 @@ func BackupTask(db *dbConfig, config *BackupConfig) {
switch config.storage {
case "local":
localBackup(db, config)
case "s3":
case "s3", "S3":
s3Backup(db, config)
case "ssh", "remote":
case "ssh", "SSH", "remote":
sshBackup(db, config)
case "ftp":
case "ftp", "FTP":
ftpBackup(db, config)
default:
localBackup(db, config)

View File

@@ -21,15 +21,15 @@ func StartRestore(cmd *cobra.Command) {
restoreConf := initRestoreConfig(cmd)
switch restoreConf.storage {
case "s3":
restoreFromS3(dbConf, restoreConf.file, restoreConf.bucket, restoreConf.s3Path)
case "local":
utils.Info("Restore database from local")
copyToTmp(storagePath, restoreConf.file)
RestoreDatabase(dbConf, restoreConf.file)
case "ssh":
case "s3", "S3":
restoreFromS3(dbConf, restoreConf.file, restoreConf.bucket, restoreConf.s3Path)
case "ssh", "SSH":
restoreFromRemote(dbConf, restoreConf.file, restoreConf.remotePath)
case "ftp":
case "ftp", "FTP":
restoreFromFTP(dbConf, restoreConf.file, restoreConf.remotePath)
default:
utils.Info("Restore database from local")