标签:web服务器
由于web服务器上的代码更新速度非常快,所以备份回滚变的非常重要,在源服务器在代码更新之前要做好备份
#!/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
标签:web服务器
原文地址:http://wks97.blog.51cto.com/2139464/1615069