更新备份脚本详细

This commit is contained in:
lsy 2024-06-18 00:48:05 +08:00
parent 85276c51f2
commit 894b8e3a46
3 changed files with 18 additions and 6 deletions

View File

@ -9,6 +9,9 @@ user="root" # 数据库用户名
password="lsy22.com" # 数据库密码 password="lsy22.com" # 数据库密码
original_dir=$(pwd) # 记录原始目录 original_dir=$(pwd) # 记录原始目录
# 激活百度网盘环境
source ~/myvenv/bin/activate
# 组合备份 # 组合备份
for item in "${mysql_arry[@]}"; do for item in "${mysql_arry[@]}"; do
# 创建SQL备份 # 创建SQL备份
@ -34,6 +37,11 @@ for item in "${mysql_arry[@]}"; do
rm "${item}_${date_time}.sql" rm "${item}_${date_time}.sql"
# 上传到云存储 # 上传到云存储
bypy upload "${item}_${date_time}.zip" "/${item}/${year}/" bypy upload "${item}_${date_time}.zip" "/${item}/${year}/"
# 上传到百度网盘存储
bypy upload "${item}_${date_time}.zip" "/${item}/"
# 上传到阿里云盘
aliyunpan upload "${item}_${date_time}.zip" "/网站/${item}/${year}/"
# 删除文件
rm "${item}_${date_time}.zip" rm "${item}_${date_time}.zip"
done done
@ -47,8 +55,11 @@ for item in "${web_arry[@]}"; do
mv "${item}_${date_time}_data.zip" "$original_dir" mv "${item}_${date_time}_data.zip" "$original_dir"
# 返回原始目录 # 返回原始目录
cd "$original_dir" || exit cd "$original_dir" || exit
# 上传到云存储 # 上传到百度网盘存储
bypy upload "${item}_${date_time}_data.zip" "/${item}/${year}/" bypy upload "${item}_${date_time}.zip" "/${item}/"
# 上传到阿里云盘
aliyunpan upload "${item}_${date_time}.zip" "/网站/${item}/${year}/"
# 删除文件
rm "${item}_${date_time}_data.zip" rm "${item}_${date_time}_data.zip"
fi fi
done done

View File

@ -5,6 +5,9 @@ date_time=$(date +"%Y_%m_%d") # 日期格式
year=$(date +"%Y") #年份 year=$(date +"%Y") #年份
original_dir=$(pwd) # 记录原始目录 original_dir=$(pwd) # 记录原始目录
# 激活百度网盘环境
source ~/myvenv/bin/activate
for item in "$web_path"/*; do for item in "$web_path"/*; do
item_name=$(basename "$item") item_name=$(basename "$item")
# 切换到网站目录进行压缩 # 切换到网站目录进行压缩
@ -14,12 +17,10 @@ for item in "$web_path"/*; do
mv "${item_name}_${date_time}.zip" "$original_dir" mv "${item_name}_${date_time}.zip" "$original_dir"
# 返回原始目录 # 返回原始目录
cd "$original_dir" || exit cd "$original_dir" || exit
# 激活百度网盘环境 # 上传到百度网盘存储
source ~/shell/myvenv/bin/activate
# 上传到云存储
bypy upload "${item_name}_${date_time}.zip" "/${item_name}/" bypy upload "${item_name}_${date_time}.zip" "/${item_name}/"
# 上传到阿里云盘 # 上传到阿里云盘
aliyunpan upload "${item_name}_${date_time}.zip" "/网站/${item_name}/${year}/" aliyunpan upload "${item_name}_${date_time}.zip" "/网站/${item_name}/${year}/"
# 删除文件 # 删除文件
rm "${item_name}_${date_time}.zip" rm "${item_name}_${date_time}.zip"
done done