From 85276c51f2b773ea4b5565fc6cf187428d058d98 Mon Sep 17 00:00:00 2001 From: lsy Date: Mon, 17 Jun 2024 21:29:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0docker=E4=B8=93=E7=94=A8?= =?UTF-8?q?=E5=A4=87=E4=BB=BD=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shell/code/webbackups_docker.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 shell/code/webbackups_docker.sh diff --git a/shell/code/webbackups_docker.sh b/shell/code/webbackups_docker.sh new file mode 100644 index 0000000..68dd29d --- /dev/null +++ b/shell/code/webbackups_docker.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +web_path="/var/www" # 数据路径 +date_time=$(date +"%Y_%m_%d") # 日期格式 +year=$(date +"%Y") #年份 +original_dir=$(pwd) # 记录原始目录 + +for item in "$web_path"/*; do + item_name=$(basename "$item") + # 切换到网站目录进行压缩 + cd "$item" || exit + zip -r "${item_name}_${date_time}.zip" . + # 移动压缩文件回原始目录 + mv "${item_name}_${date_time}.zip" "$original_dir" + # 返回原始目录 + cd "$original_dir" || exit + # 激活百度网盘环境 + source ~/shell/myvenv/bin/activate + # 上传到云存储 + 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" +done