修复备份脚本错误,添加删除第一次备份临时文件

This commit is contained in:
lsy2246 2024-04-06 18:17:22 +08:00
parent 2275a7a3e7
commit 17506e7b90

View File

@ -12,14 +12,16 @@ for item in ${mysql_arry[@]};do
mkdir -p "$item/$year" mkdir -p "$item/$year"
mysqldump -u $user -p$password ${item} > "${item}_${date_time}.sql" mysqldump -u $user -p$password ${item} > "${item}_${date_time}.sql"
zip "./$item/$year/${item}_${date_time}.zip" "./${item}_${date_time}.sql" zip "./$item/$year/${item}_${date_time}.zip" "./${item}_${date_time}.sql"
rm "./${item}_${date_time}.sql"
done done
for item in ${web_arry[@]};do for item in ${web_arry[@]};do
mkdir -p "./$item/$year" mkdir -p "./$item/$year"
zip -r "./${item}_${date_time}_data.zip" "/${item}" zip -r "./${item}_${date_time}_data.zip" "${web_path}/${item}"
if [ -f "./$item/$year/${item}_${date_time}.zip" ];then if [ -f "./$item/$year/${item}_${date_time}.zip" ];then
zip -u "./${item}_${date_time}.zip" "./${item}_${date_time}_data.zip" zip -u "./$item/$year/${item}_${date_time}.zip" "./${item}_${date_time}_data.zip"
else else
zip "./$item/$year/${item}_${date_time}.zip" "./${item}_${date_time}_data.zip" zip "./$item/$year/${item}_${date_time}.zip" "./${item}_${date_time}_data.zip"
fi fi
rm "./${item}_${date_time}_data.zip"
done done