网站备份脚本
This commit is contained in:
parent
458f2bf2b3
commit
56a6788f77
25
shell/code/backups.sh
Normal file
25
shell/code/backups.sh
Normal file
@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
web_path="/var/www"
|
||||
web_arry=("alist" "bitwarden" "blog")
|
||||
mysql_arry=("blog" "study")
|
||||
date_time=$(date +"%Y_%m_%d")
|
||||
year=$(date +"%Y")
|
||||
user=""
|
||||
password=""
|
||||
|
||||
for item in ${mysql_arry[@]};do
|
||||
mkdir -p "$item/$year"
|
||||
mysql -u $user -p$password ${item} > "${item}_${date_time}.sql"
|
||||
zip "./$item/$year/${item}_${date_time}.zip" "./${item}_${date_time}.sql"
|
||||
done
|
||||
|
||||
for item in ${web_arry[@]};do
|
||||
mkdir -p "./$item/$year"
|
||||
zip -r "./${item}_${date_time}_data.zip" "/${item}"
|
||||
if [ -f "./$item/$year/${item}_${date_time}.zip" ];then
|
||||
zip -u "./${item}_${date_time}.zip" "./${item}_${date_time}_data.zip"
|
||||
else
|
||||
zip "./$item/$year/${item}_${date_time}.zip" "./${item}_${date_time}_data.zip"
|
||||
fi
|
||||
done
|
Loading…
Reference in New Issue
Block a user