From 181763db424230c22ee9d295b979cb9ed68f8b4a Mon Sep 17 00:00:00 2001 From: lsy Date: Fri, 26 Jul 2024 21:35:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=A4=87=E4=BB=BDdocker?= =?UTF-8?q?=E5=91=BD=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shell/code/backups/backups_cloud_docker.sh | 22 +++++++++++++++++ .../backups_file_mysql_cloud_docker.sh | 24 ------------------- 2 files changed, 22 insertions(+), 24 deletions(-) create mode 100644 shell/code/backups/backups_cloud_docker.sh delete mode 100644 shell/code/backups/backups_file_mysql_cloud_docker.sh diff --git a/shell/code/backups/backups_cloud_docker.sh b/shell/code/backups/backups_cloud_docker.sh new file mode 100644 index 0000000..33a4e23 --- /dev/null +++ b/shell/code/backups/backups_cloud_docker.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +web_path="/var/www" # 数据路径 +date_time=$(date +"%Y_%m_%d") # 日期格式 +year=$(date +"%Y") #年份 +aliyunpan="/var/script/aliyunpan/aliyunpan" #阿里云盘可执行文件路径 + +# 激活百度网盘环境 +source "/var/script/venv/bin/activate" + +for item in "$web_path"/*; do + item_name=$(basename "$item") + # 切换到网站目录进行压缩 + cd "$item" || exit + tar -czf "${item_name}_${date_time}.tar.gz" . + # 上传到百度网盘存储 + bypy upload "${item_name}_${date_time}.tar.gz" "/${item_name}/" + # 上传到阿里云盘 + $aliyunpan upload "${item_name}_${date_time}.tar.gz" "/网站/${item_name}/${year}/" + # 删除文件 + rm "${item_name}_${date_time}.tar.gz" +done \ No newline at end of file diff --git a/shell/code/backups/backups_file_mysql_cloud_docker.sh b/shell/code/backups/backups_file_mysql_cloud_docker.sh deleted file mode 100644 index 20e0b7c..0000000 --- a/shell/code/backups/backups_file_mysql_cloud_docker.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -web_path="/var/www" # 数据路径 -date_time=$(date +"%Y_%m_%d") # 日期格式 -year=$(date +"%Y") #年份 -original_dir=$(pwd) # 记录原始目录 - -# 激活百度网盘环境 -source ~/myvenv/bin/activate - -for item in "$web_path"/*; do - item_name=$(basename "$item") - # 切换到网站目录进行压缩 - cd "$item" || exit - zip -r "${item_name}_${date_time}.zip" . - # 上传到百度网盘存储 - bypy upload "${item_name}_${date_time}.zip" "/${item_name}/" - # 上传到阿里云盘 - aliyunpan upload "${item_name}_${date_time}.zip" "/网站/${item_name}/${year}/" - # 删除文件 - rm "${item_name}_${date_time}.zip" - # 返回原始目录 - cd "$original_dir" || exit -done \ No newline at end of file