forked from linuxeye/lnmp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
backup.sh
executable file
·61 lines (55 loc) · 2.03 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
56
57
58
59
60
61
#!/bin/bash
# Author: yeho <lj2007331 AT gmail.com>
# BLOG: https://blog.linuxeye.com
#
# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+
#
# Project home page:
# http://oneinstack.com
# https://github.com/lj2007331/oneinstack
cd tools
. ../options.conf
DB_Local_BK() {
for D in `echo $db_name | tr ',' ' '`
do
./db_bk.sh $D
done
}
DB_Remote_BK() {
for D in `echo $db_name | tr ',' ' '`
do
./db_bk.sh $D
DB_GREP="DB_${D}_`date +%Y`"
DB_FILE=`ls -lrt $backup_dir | grep ${DB_GREP} | tail -1 | awk '{print $NF}'`
echo "file:::$backup_dir/$DB_FILE $backup_dir push" >> config_bakcup.txt
echo "com:::[ -e "$backup_dir/$DB_FILE" ] && rm -rf $backup_dir/DB_${D}_$(date +%Y%m%d --date="$expired_days days ago")_*.tgz" >> config_bakcup.txt
done
}
WEB_Local_BK() {
for W in `echo $website_name | tr ',' ' '`
do
./website_bk.sh $W
done
}
WEB_Remote_BK() {
for W in `echo $website_name | tr ',' ' '`
do
echo "file:::$wwwroot_dir/$W $backup_dir push" >> config_bakcup.txt
done
}
if [ "$backup_destination" == 'local' ];then
[ -n "`echo $backup_content | grep -ow db`" ] && DB_Local_BK
[ -n "`echo $backup_content | grep -ow web`" ] && WEB_Local_BK
elif [ "$backup_destination" == 'remote' ];then
echo "com:::[ ! -e "$backup_dir" ] && mkdir -p $backup_dir" > config_bakcup.txt
[ -n "`echo $backup_content | grep -ow db`" ] && DB_Remote_BK
[ -n "`echo $backup_content | grep -ow web`" ] && WEB_Remote_BK
./mabs.sh -c config_bakcup.txt -T -1 | tee mabs.log
elif [ "$backup_destination" == 'local,remote' ];then
echo "com:::[ ! -e "$backup_dir" ] && mkdir -p $backup_dir" > config_bakcup.txt
[ -n "`echo $backup_content | grep -ow db`" ] && DB_Local_BK
[ -n "`echo $backup_content | grep -ow web`" ] && WEB_Local_BK
[ -n "`echo $backup_content | grep -ow db`" ] && DB_Remote_BK
[ -n "`echo $backup_content | grep -ow web`" ] && WEB_Remote_BK
./mabs.sh -c config_bakcup.txt -T -1 | tee mabs.log
fi