From e677900e8a53f37850967baa2efd5b85253fb932 Mon Sep 17 00:00:00 2001 From: xuwei-fit2cloud Date: Tue, 23 Apr 2024 14:17:10 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BC=98=E5=8C=96=20dectl=20?= =?UTF-8?q?=E5=A4=87=E4=BB=BD=E8=84=9A=E6=9C=AC=EF=BC=8C=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=A4=87=E4=BB=BD=E5=89=8D=E5=81=9C=E6=AD=A2=E6=9C=8D=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- installer/dectl | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/installer/dectl b/installer/dectl index 35944b2d7e..845962117a 100644 --- a/installer/dectl +++ b/installer/dectl @@ -320,6 +320,34 @@ function clear_images() { fi } function backup() { + need_stop=0 + if [[ -z $1 ]];then + echo "如需备份 DataEase 数据,建议您先停止 DataEase 服务,以保证备份数据的完整性。" + read -r -p "即将备份 DataEase 数据,是否需要停止 DataEase 服务? [Y/n] " input + + case $input in + [yY][eE][sS]|[yY]) + echo "Yes" + need_stop=1 + ;; + [nN][oO]|[nN]) + echo "No" + ;; + *) + echo "无效输入..." + exit 1 + ;; + esac + elif [[ "$1" == "stop" ]];then + need_stop=1 + fi + + if [[ $need_stop == 1 ]];then + service dataease stop + else + echo "不停服进行备份" + fi + backup_file_name=dataease-backup-$(date +%Y%m%d)_$(date +%H%M%S).tar.gz tar --exclude=logs/dataease -zcf $backup_file_name -C $DE_RUNNING_BASE . if [ $? -ne 0 ]; then @@ -328,6 +356,10 @@ function backup() { else echo "备份成功,备份文件 : $backup_file_name" fi + + if [[ $need_stop == 1 ]];then + service dataease start + fi } function restore() { if [[ -z $target ]];then @@ -367,7 +399,7 @@ function main() { upgrade ;; backup) - backup + backup $target ;; restore) restore $target