Share a script that leverages SVN line code in a production environment

Source: Internet
Author: User

This article is about the use of Svn+rsync line code production case, for small companies and enterprises, so that operations from the frequent release of the line code. The following Web servers are also available for Windows servers and Linux servers

Repos= "$" rev= "$" export lang=zh_cn. Utf-8export rsync_password=rsync_passwordrsync_user=rsync_userproject_name= ' basename  $REPOS ' SVN_DIR= /svndata/project/${project_name}/web_dir=/app/${project_name}/host_conf= "/svndata/conf/host/${project_name}" exclude_conf= "/svndata/conf/exclude/${project_name}.txt" if [ ! -d  $WEB _dir ]; thenmkdir -p  $WEB _dir/usr/bin/svn checkout file://$SVN _dir  $WEB _direlse/usr/bin/svn  update  $WEB _dirfitest -f  $HOST _conf | |  exit 3dev_version= '/usr/bin/svnlook changed  $SVN _dir|grep  "Dev" |awk  ' {print  $2} ' |awk -f '/'   ' {print $2} ' |head -n1 ' if [  $DEV _version ];then         for HOST in  ' cat  $HOST _conf|sed  ' s/^[  \t]*//g ' |grep -v  ' ^# ' |grep  ' dev: ' |awk -f ': '   ' {print $2} '          do        /usr/bin/rsync -rvzp --delete --port=873 -- Exclude= '. svn/'    $WEB _dir/dev/  [email protected]${host}::${project_name} > >/tmp/dev_${project_name}_ ' date +%y%m%d '. log        donefitags _check= '/usr/bin/svnlook changed  $SVN _dir|grep  ' tags ' |awk  ' {print $1} ' |grep -E   "a| U " |wc -l ' if [  $tags _check -ne 0 ];then         tags_version= '/usr/bin/svnlook changed  $SVN _dir|grep  "TAGS" |awk  ' {print $ 2} ' |awk -f '/'   ' {print $2} ' |head -n1 '         tags_ Size= ' du -s  $WEB _dir/tags/${tags_version}|awk  ' {print $1} '          if [  $TAGS _version ] && [  $TAGS _size -gt 20  ];then        for host in  ' cat  $HOST _conf|sed  ' s/^[  \t]*//g ' |grep -v  ' ^# ' |grep  ' Tags: ' |awk -f ': '   ' {print $2} '          do        echo  "' date +% y-%m-%d_%h:%m:%s '  start to sync  $PROJECT _name to ${host} webserver  " >>/tmp/tags_${project_name}_ ' date +%y%m%d '. log        /usr/ bin/rsync -rvzp --delete --port=873 --exclude-from=${exclude_conf}   $WEB _dir/ Tags/${tags_version}/ [email protected]${host}::${project_name} >>/tmp/tags_${project_ Name}_ ' date +%y%m%d ' .log        echo  "sync end to  ${host} ">>/tmp/tags_${project_name}_ ' date +%y%m%d ' .log         done        echo  "# # ' date +%y-%m-%d_%h:%m:%s ' ############################# ################## ">>/tmp/tags_${project_name}_ ' date +%y%m%d ' .log         fifiunset rsync_passwordexit 0


Host configuration file host_conf

dev:192.168.2.21tags:192.168.2.30tags:192.168.2.30

#dev只有一个

#tags可以有多个


Exclude Files Exclude_conf

. svn/check_chk.htmlindex.html

Can implement some files do not sync, such as generated cache and uploaded pictures and so on


Process:

There are 2 folders under the project, and SVN determines the folder directory to be submitted to determine whether the test server or the production server are synchronized.

Dev

Tags

2 directories


The developer submits the tested program to the Dev directory, and the program is automatically synchronized to the test server for testing.

By the tester, after the test OK, add the application to the production server in increments or full volume


Incremental on-line:

For example, the developer added or modified the a.php file under Dev, now only need to put this file to the nearest tags/{version number}/the corresponding directory below can


Full-volume on-line:

Only need to take advantage of SVN's new branch function, the branch path is/dev/{custom version number}, you can achieve full-scale online


Rollback:

Use SVN to retrieve the previous version, then overwrite the submission


If you have any questions, don't hesitate to enlighten me!

This article is from "Maple Night" blog, please be sure to keep this source http://fengwan.blog.51cto.com/508652/1747824

Share a script that leverages SVN line code in a production environment

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.