由于web服务器上的代码更新速度非常快,所以备份回滚变的非常重要,在源服务器在代码更新之前要做好备份
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
|
#!/bin/bash
TODAY=`
date
+
'%Y%m%d%H%M%S'
`
BACKUP_DIR=
/home/path_to_file/publish/FILENAMEback
FILE_DIR=
/PATH/TO/FILE
find
$FILE_DIR/ -
type
f >
/home/publish_file
.list
sed
-i
's/\/PATH\/TO\/FILE\>//g'
/home/pubilsh_file
.list
if
[ ! -d $BACKUP_DIR$TODAY ];
then
mkdir
-p $BACKUP_DIR$TODAY
fi
for
s
in
$(
cat
/home/publish_file
.list)
do
if
[ ! -d $BACKUP_DIR$TODAY${s%/*} ];
then
mkdir
-p $BACKUP_DIR$TODAY${s%/*}
fi
done
for
s
in
$(
cat
/home/publish_file
.list)
do
/bin/cp
-fr
/var/www/html
$s $BACKUP_DIR$TODAY$s
done
find
$BACKUP_DIR$TODAY -
type
f
if
[ $? = 0 ];
then
/bin/cp
-fr $FILE_DIR
/projectname
/var/www/html/projectname
rm
-rf $FILE_DIR/*
fi
|
本文转自wks9751CTO博客,原文链接:http://blog.51cto.com/wks97/1615069
,如需转载请自行联系原作者