From 56a6788f77a82c3ddf1a8d90deaf607e49b3f7ce Mon Sep 17 00:00:00 2001 From: lsy2246 Date: Sat, 6 Apr 2024 17:38:28 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BD=91=E7=AB=99=E5=A4=87=E4=BB=BD=E8=84=9A?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shell/code/backups.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 shell/code/backups.sh diff --git a/shell/code/backups.sh b/shell/code/backups.sh new file mode 100644 index 0000000..14ef967 --- /dev/null +++ b/shell/code/backups.sh @@ -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