From 842f16a3aeed8bda46283df08ee7707983df8d69 Mon Sep 17 00:00:00 2001 From: jeessy2 <6205259+jeessy2@users.noreply.github.com> Date: Tue, 19 Jul 2022 17:14:00 +0800 Subject: [PATCH] feat: project supports enabled or disabled (#32) --- client/backup.go | 9 +++++++-- entity/config_backup.go | 1 + web/save.go | 2 ++ web/writing.html | 26 ++++++++++++++++---------- 4 files changed, 26 insertions(+), 12 deletions(-) diff --git a/client/backup.go b/client/backup.go index 7bd3f3a..2bcd714 100644 --- a/client/backup.go +++ b/client/backup.go @@ -39,8 +39,13 @@ func RunLoop() { continue } + if backupConf.Enabled != 0 { + log.Println(backupConf.ProjectName + " 项目被停用") + continue + } + if !backupConf.CheckPeriod() { - log.Println(backupConf.ProjectName + "的周期值不正确") + log.Println(backupConf.ProjectName + " 项目的周期值不正确") continue } @@ -88,7 +93,7 @@ func RunOnce() { // run func run(conf entity.Config, backupConf entity.BackupConfig) { - if backupConf.NotEmptyProject() { + if backupConf.NotEmptyProject() && backupConf.Enabled == 0 { err := prepare(backupConf) if err != nil { log.Println(err) diff --git a/entity/config_backup.go b/entity/config_backup.go index 34deac0..228b328 100644 --- a/entity/config_backup.go +++ b/entity/config_backup.go @@ -10,6 +10,7 @@ type BackupConfig struct { Period int // 间隔周期(分钟) Pwd string // 密码 BackupType int // 备份类型 0 数据库备份 1 文件同步 + Enabled int // 是否启用 0 启用 1 停用 } // GetProjectPath 获得项目路径 diff --git a/web/save.go b/web/save.go index bd5e3e2..05ac799 100644 --- a/web/save.go +++ b/web/save.go @@ -48,6 +48,7 @@ func Save(writer http.ResponseWriter, request *http.Request) { startTime, _ := strconv.Atoi(forms["StartTime"][index]) period, _ := strconv.Atoi(forms["Period"][index]) backupType, _ := strconv.Atoi(forms["BackupType"][index]) + enabled, _ := strconv.Atoi(forms["Enabled"][index]) conf.BackupConfig = append( conf.BackupConfig, entity.BackupConfig{ @@ -59,6 +60,7 @@ func Save(writer http.ResponseWriter, request *http.Request) { Period: period, Pwd: forms["Pwd"][index], BackupType: backupType, + Enabled: enabled, }, ) } diff --git a/web/writing.html b/web/writing.html index 7273d5e..4946c30 100644 --- a/web/writing.html +++ b/web/writing.html @@ -70,27 +70,33 @@
备份设置
- 日期变量 #{DATE} ,下方的密码变量 #{PWD} ,下方的对象存储变量: #{Endpoint} #{AccessKey} #{SecretKey} #{BucketName} + 日期变量 #{DATE} ,密码变量 #{PWD} ,对象存储变量: #{Endpoint} #{AccessKey} #{SecretKey} #{BucketName}
例: mysqldump -h192.168.1.11 -uroot -p#{PWD} db-name > #{DATE}.sql 备份脚本参考
- +
- - 如果没有输出文件, 请选择同步文件 +
- -
- + +
+ +
+ +
+