forked from chunjie-sam-liu/useful-scripts
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbackup-databases.sh
More file actions
executable file
·38 lines (32 loc) · 944 Bytes
/
backup-databases.sh
File metadata and controls
executable file
·38 lines (32 loc) · 944 Bytes
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
#########################################################################
# File Name: backup_databases.sh
# Author: C.J. Liu
# Mail: samliu@hust.edu.cn
# Created Time: Thu 15 Mar 2018 04:27:45 PM CST
#########################################################################
#!/bin/bash
# Directory
web=/home/liucj/web
web_backup=/home/liucj/tmp/web_backup
s3_backup=/home/liucj/data/web_backup
# For logs
scpd=/home/liucj/scripts
backup_time=`date +"%y-%m"`
log=${scpd}/.webbackup_${backup_time}.log
zipweb () {
# $1 is the web name
dest=${web_backup}/${1}_$backup_time.tar.gz
src=${web}/$1
echo "Notice: Backup ${1} to ${dest}!" >> ${log}
cmd="tar -zcvf ${dest} ${src} >> ${log}"
echo ${cmd} >> $log
eval ${cmd}
echo "Notice: Backup ${dest} to server 3" >> ${log}
cmd="copyto.sh 3 ${s3_backup} ${dest} >> ${log}"
echo ${cmd} >> $log
eval ${cmd}
}
for w in `ls ${web}`
do
zipweb ${w}
done