web代码发布脚本以及回滚3.0
由于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
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。