forked from github/dataease
Merge pull request #9269 from dataease/pr@v2_refactor_dectl
refactor: 优化 dectl 备份脚本,支持备份前停止服务
This commit is contained in:
commit
a24aa33ea7
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user