mirror of
https://github.com/jkaninda/mysql-bkup.git
synced 2025-12-06 13:39:41 +01:00
ci: add Docker tests (#179)
This commit is contained in:
@@ -51,6 +51,7 @@ func StartBackup(cmd *cobra.Command) {
|
||||
if err != nil {
|
||||
dbConf = initDbConfig(cmd)
|
||||
if config.cronExpression == "" {
|
||||
config.allowCustomName = true
|
||||
createBackupTask(dbConf, config)
|
||||
} else {
|
||||
if utils.IsValidCronExpression(config.cronExpression) {
|
||||
@@ -145,11 +146,18 @@ func backupTask(db *dbConfig, config *BackupConfig) {
|
||||
if config.all && config.allInOne {
|
||||
prefix = "all_databases"
|
||||
}
|
||||
|
||||
// Generate file name
|
||||
backupFileName := fmt.Sprintf("%s_%s.sql.gz", prefix, time.Now().Format("20060102_150405"))
|
||||
if config.disableCompression {
|
||||
backupFileName = fmt.Sprintf("%s_%s.sql", prefix, time.Now().Format("20060102_150405"))
|
||||
}
|
||||
if config.customName != "" && config.allowCustomName && !config.all {
|
||||
backupFileName = fmt.Sprintf("%s.sql.gz", config.customName)
|
||||
if config.disableCompression {
|
||||
backupFileName = fmt.Sprintf("%s.sql", config.customName)
|
||||
}
|
||||
}
|
||||
config.backupFileName = backupFileName
|
||||
s := strings.ToLower(config.storage)
|
||||
switch s {
|
||||
|
||||
@@ -79,6 +79,8 @@ type BackupConfig struct {
|
||||
cronExpression string
|
||||
all bool
|
||||
allInOne bool
|
||||
customName string
|
||||
allowCustomName bool
|
||||
}
|
||||
type FTPConfig struct {
|
||||
host string
|
||||
@@ -259,6 +261,7 @@ func initBackupConfig(cmd *cobra.Command) *BackupConfig {
|
||||
prune = true
|
||||
}
|
||||
disableCompression, _ = cmd.Flags().GetBool("disable-compression")
|
||||
customName, _ := cmd.Flags().GetString("custom-name")
|
||||
all, _ := cmd.Flags().GetBool("all-databases")
|
||||
allInOne, _ := cmd.Flags().GetBool("all-in-one")
|
||||
if allInOne {
|
||||
@@ -295,6 +298,7 @@ func initBackupConfig(cmd *cobra.Command) *BackupConfig {
|
||||
config.cronExpression = cronExpression
|
||||
config.all = all
|
||||
config.allInOne = allInOne
|
||||
config.customName = customName
|
||||
return &config
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user