From 7baf675f759da95846f9e2c907a66fa0b9ddbe44 Mon Sep 17 00:00:00 2001 From: xuwei-fit2cloud Date: Mon, 5 Feb 2024 17:21:03 +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/dataease/dectl | 57 ++++++++++++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 11 deletions(-) diff --git a/installer/dataease/dectl b/installer/dataease/dectl index 2630be7681..8c5cbc1757 100755 --- a/installer/dataease/dectl +++ b/installer/dataease/dectl @@ -47,16 +47,18 @@ function usage() { echo " ./dectl --help" echo echo "Commands: " - echo " status 查看 DATAEASE 服务运行状态" - echo " start 启动 DATAEASE 服务" - echo " stop 停止 DATAEASE 服务" - echo " restart 重启 DATAEASE 服务" - echo " reload 重新加载 DATAEASE 服务" - echo " uninstall 卸载 DATAEASE 服务" - echo " upgrade 升级 DATAEASE 服务" - echo " version 查看 DATAEASE 版本信息" - echo " clear-images 清理 DATAEASE 旧版本的相关镜像" - echo " clear-logs 清理 DATAEASE 历史日志以及 Doris 临时日志" + echo " status 查看 DATAEASE 服务运行状态" + echo " start 启动 DATAEASE 服务" + echo " stop 停止 DATAEASE 服务" + echo " restart 重启 DATAEASE 服务" + echo " reload 重新加载 DATAEASE 服务" + echo " uninstall 卸载 DATAEASE 服务" + echo " upgrade 升级 DATAEASE 服务" + echo " backup 备份 DATAEASE 服务" + echo " restore xxx.tar.gz 还原 DATAEASE 服务" + echo " version 查看 DATAEASE 版本信息" + echo " clear-images 清理 DATAEASE 旧版本的相关镜像" + echo " clear-logs 清理 DATAEASE 历史日志以及 Doris 临时日志" } function _healthcheck() { echo @@ -293,7 +295,34 @@ function upgrade() { cd .. rm -rf /tmp/dataease-${latest_version}-online } - +function backup() { + echo "开始备份,建议在备份时先停止 DataEase 服务!" + backup_file_name=dataease-backup-$(date +%Y%m%d)_$(date +%H%M%S).tar.gz + tar --exclude=logs/* -zcf $backup_file_name -C $DE_BASE/dataease . + 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_BASE/dataease ]];then + mkdir -p $DE_BASE/dataease + fi + echo "恢复备份 $target" + tar -zxf $target --directory=$DE_BASE/dataease + service dataease start + else + echo "未找到备份文件 $target!" + exit 1 + fi +} function main() { case "${action}" in status) @@ -317,6 +346,12 @@ function main() { upgrade) upgrade ;; + backup) + backup + ;; + restore) + restore $target + ;; version) version ;;