forked from linuxeye/lnmp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
backup.sh
executable file
·55 lines (50 loc) · 1.53 KB
/
backup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
# Author: yeho <lj2007331 AT gmail.com>
# Blog: http://blog.linuxeye.com
. ./options.conf
DB_Local_BK() {
for D in `echo $db_name | tr ',' ' '`
do
cd $lnmp_dir/tools
./db_bk.sh $D
done
}
DB_Remote_BK() {
for D in `echo $db_name | tr ',' ' '`
do
cd $lnmp_dir/tools
./db_bk.sh $D
echo "file:::$backup_dir/DB_${D}_$(date +%Y%m%d).tgz $backup_dir push" >> $lnmp_dir/tools/config.txt
echo "com:::[ -e "$backup_dir/DB_${D}_$(date +%Y%m%d).tgz" ] && rm -rf $backup_dir/DB_${D}_$(date +%Y%m%d --date="$expired_days days ago").tgz" >> $lnmp_dir/tools/config.txt
done
}
WEB_Local_BK() {
for W in `echo $website_name | tr ',' ' '`
do
cd $lnmp_dir/tools
./website_bk.sh $W
done
}
WEB_Remote_BK() {
for W in `echo $website_name | tr ',' ' '`
do
cd $lnmp_dir/tools
echo "file:::$home_dir/$W $backup_dir push" >> $lnmp_dir/tools/config.txt
done
}
if [ "$local_bankup_yn" == 'y' -a "$remote_bankup_yn" == 'n' ];then
WEB_Local_BK
DB_Local_BK
elif [ "$local_bankup_yn" == 'n' -a "$remote_bankup_yn" == 'y' ];then
echo "com:::[ ! -e "$backup_dir" ] && mkdir -p $backup_dir" > $lnmp_dir/tools/config.txt
DB_Remote_BK
WEB_Remote_BK
./mabs.sh | tee mabs.log
elif [ "$local_bankup_yn" == 'y' -a "$remote_bankup_yn" == 'y' ];then
echo "com:::[ ! -e "$backup_dir" ] && mkdir -p $backup_dir" > $lnmp_dir/tools/config.txt
WEB_Local_BK
WEB_Remote_BK
DB_Local_BK
DB_Remote_BK
./mabs.sh | tee mabs.log
fi