From ceed75c54567e4b56bbef31b686932bb914c3cb4 Mon Sep 17 00:00:00 2001 From: xuwei-fit2cloud Date: Mon, 5 Feb 2024 16:19:12 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20dectl=20=E5=A2=9E=E5=8A=A0=E5=A4=87?= =?UTF-8?q?=E4=BB=BD=E5=92=8C=E6=81=A2=E5=A4=8D=E5=8A=9F=E8=83=BD=20#6602?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- installer/dectl | 51 +++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 43 insertions(+), 8 deletions(-) diff --git a/installer/dectl b/installer/dectl index 4490f559f1..b02d0001ca 100644 --- a/installer/dectl +++ b/installer/dectl @@ -36,14 +36,16 @@ function usage() { echo " ./dectl --help" echo echo "Commands: " - echo " status 查看 DATAEASE 服务运行状态" - echo " start 启动 DATAEASE 服务" - echo " stop 停止 DATAEASE 服务" - echo " restart 重启 DATAEASE 服务" - echo " reload 重新加载 DATAEASE 服务" - echo " upgrade 升级 DATAEASE 服务" - echo " clear-images 清理 DATAEASE 旧版本的相关镜像" - echo " version 查看 DATAEASE 版本" + echo " status 查看 DATAEASE 服务运行状态" + echo " start 启动 DATAEASE 服务" + echo " stop 停止 DATAEASE 服务" + echo " restart 重启 DATAEASE 服务" + echo " reload 重新加载 DATAEASE 服务" + echo " upgrade 升级 DATAEASE 服务" + echo " backup 备份 DATAEASE 服务" + echo " restore xxx.tar.gz 还原 DATAEASE 服务" + echo " clear-images 清理 DATAEASE 旧版本的相关镜像" + echo " version 查看 DATAEASE 版本" } function _generate_compose_file_args() { if [[ $DE_INSTALL_MODE != "community" ]];then @@ -323,6 +325,33 @@ function clear_images() { echo "清理完毕" fi } +function backup() { + 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 + echo "备份失败" + exit 1 + else + echo "备份成功,备份文件 : $backup_file_name" + fi +} +function restore() { + if [[ -z $target ]];then + echo "未指定需要恢复的备份文件!" + exit 1 + elif [[ -f $target ]];then + service dataease stop + if [[ ! -d $DE_RUNNING_BASE ]];then + mkdir -p $DE_RUNNING_BASE + fi + echo "恢复备份 $target" + tar -zxf $target --directory=$DE_RUNNING_BASE + service dataease start + else + echo "未找到备份文件 $target!" + exit 1 + fi +} function main() { case "${action}" in status) @@ -343,6 +372,12 @@ function main() { upgrade) upgrade ;; + backup) + backup + ;; + restore) + restore $target + ;; clear-images) clear_images ;;