Svn combined with rsync code publishing system, svnrsync

Source: Internet
Author: User
Tags svn update

Svn combined with rsync code publishing system, svnrsync

Submitted by development to the test environment, tested, and released in a unified manner by O & M. The test requires a test server and an online (production environment) server. Svn running on the test server is developed for code management, while svn running online is used for code online O & M. Use rsync to keep the code on the test end consistent with that on the svn online control end (online svn, A workcopy on the test server. Developers work with O & M personnel and submit code cyclically by O & M personnel. If there is a problem, roll back to ensure that the Code is online normally !!

On the svn server, a chackout workcopy is on the client: (pay attention to the firewall)

[root@v03-svn-client ~]# svn co svn://192.168.1.35/webtest client_webtestAuthentication realm: <svn://192.168.1.35:3690> 18ab87c6-8455-4174-a313-7b6fd3775a73Password for 'root': Authentication realm: <svn://192.168.1.35:3690> 18ab87c6-8455-4174-a313-7b6fd3775a73Username: svnadminPassword for 'svnadmin': Authentication realm: <svn://192.168.1.35:3690> 18ab87c6-8455-4174-a313-7b6fd3775a73Username: user01Password for 'user01': -----------------------------------------------------------------------ATTENTION!  Your password for authentication realm:   <svn://192.168.1.35:3690> 18ab87c6-8455-4174-a313-7b6fd3775a73can only be stored to disk unencrypted!  You are advised to configureyour system so that Subversion can store passwords encrypted, ifpossible.  See the documentation for details.You can avoid future appearances of this warning by setting the valueof the 'store-plaintext-passwords' option to either 'yes' or 'no' in'/root/.subversion/servers'.-----------------------------------------------------------------------Store password unencrypted (yes/no)? yesA    client_webtest/default.htmlA    client_webtest/default1.htmlA    client_webtest/k.txtA    client_webtest/index.htmlA    client_webtest/index.phpChecked out revision 40.

 

[root@v03-svn-client ~]# tree client_webtest/client_webtest/├── default1.html├── default.html├── index.html├── index.php└── k.txt0 directories, 5 files
[root@v01-svn-test-server www]# svn co svn://192.168.1.35/online

The above command is to check out workcopy (online) under the root directory of the website and create a new directory localsvn, which is the same as synchronizing the online (except. svn) hosts files to localsvn through rsync.

[root@v01-svn-test-server www]# lsauthz       index.php  online  phpwind  rsync_test.sh  webtestindex.html  localsvn   passwd  project  svnserve.conf

 

[Root @ v01-svn-test-server www] # svn co svn: // 192.168.1.65/webtest localsvn # From the online svn server chackout culture workcopy and rename it as localsvn for the price increase code on the network

 

 

Compile the svn (test server) Hook code:

[root@v01-svn-test-server hooks]# lspost-commit               post-unlock.tmpl         pre-unlock.tmplpost-commit.tmpl          pre-commit.tmpl          start-commit.tmplpost-lock.tmpl            pre-lock.tmplpost-revprop-change.tmpl  pre-revprop-change.tmpl[root@v01-svn-test-server hooks]# pwd/svn/webtest/hooks

 

[Root @ v01-svn-test-server www] # cd/svn/webtest/hooks/[root @ v01-svn-test-server hooks] # vi post-commitREPOS = "$1" REV = "$2" SVN =/ usr/bin/svnLOCALSVN =/alidata/www/localsvnWEB =/alidata/www/onlineRSYNC =/usr/bin/rsyncLOG =/alidata/log/svn. logexport LANG = en_US.UTF-8 $ SVN update $ WEB -- username user01 -- password 123if [$? = 0]; thenecho ""> $ LOGecho 'date'> $ LOGecho "######################### ### "> $ LOG $ RSYNC-vr -- exclude = ". svn "-- delete $ WEB/$ LOCALSVN >>$ LOGfi # rsync parameter -- exclude = ". svn "is a division. svn synchronization; -- delete: delete files that do not exist in the source directory of the target directory to ensure that the target directory is consistent with the source directory (this is critical !!)

 

[Root @ v03-svn-client client_webtest] # pwd/root/client_webtest [root @ v03-svn-client client_webtest] # echo "client submit code to svn service"> test.txt [root @ v03-svn-client client_webtest] # cat the test.txt client submits code to the svn service.

 

[root@v03-svn-client client_webtest]# svn status ?       test.txt

 

[Root @ v03-svn-client client_webtest] # svn add test.txt A (bin) test.txt [root @ v03-svn-client client_webtest] # svn ci-m "client end add file" test.txt Adding (bin) test.txt Transmitting file data. committed revision 43.

 

[Root @ v01-svn-test-server online] # svn status [root @ v01-svn-test-server online] # cat test.txt Client client submits code to the svn service [root @ v01-svn-test-server online] # code successfully synchronized to the test environment

 

[Root @ v01-svn-test-server localsvn] # lsdefault1.html default.html index.html index. php test.txt [root @ v01-svn-test-server localsvn] # cat test.txt client submit code to svn service [root @ v01-svn-test-server localsvn] # svn status? Test.txt # Use rsync-vr -- exclude = ". svn" -- delete/alidata/www/online/alidata/www/localsvn to synchronize code

Then go online according to the development. (ALL or specific code is allowed !!)

[Root @ v03-svn-client client_webtest] # echo "Update code ---" 1 "> test.txt [root @ v03-svn-client client_webtest] # touch test2.txt pull new code test.txt [root @ v03-svn-client client_webtest] # svn status? Test2.txtM test.txt [root @ v03-svn-client client_webtest] # svn add test2.txt A test2.txt [root @ v03-svn-client client_webtest] # svn ci-m "'Update code --- '> test.txt new code test.txt" Sending test.txt "adding test2.txtTransmitting file data .. committed revision 44.

 

[Root @ v01-svn-test-server online] # pwd/alidata/www/online [root @ v01-svn-test-server online] # lsdefault1.html default.html index.html index. php test2.txt test.txt [root @ v01-svn-test-server online] # cat test.txt Client client submit code to svn service update code --- 1 [root @ v01-svn-test-server online] # svn status [root @ v01-svn-test-server online] # code root succeeded !!!

 

[Root @ v01-svn-test-server localsvn] # pwd/alidata/www/localsvn [root @ v01-svn-test-server localsvn] # lsdefault1.html default.html index.html index. php test2.txt test.txt [root @ v01-svn-test-server localsvn] # cat test.txt Client client submitted code to the svn service to update the code --- "1 [root @ v01-svn-test-server localsvn] # svn status? Test2.txt? Test.txt # synchronization succeeded through rsync!

Verify: whether the source directory file is synchronized from time to time, and the package is deleted!

[root@v03-svn-client client_webtest]# lsdefault1.html  default.html  index.html  index.php  test2.txt  test.txt[root@v03-svn-client client_webtest]# svn status[root@v03-svn-client client_webtest]# lsdefault1.html  default.html  index.html  index.php  test2.txt  test.txt[root@v03-svn-client client_webtest]# svn delete test2.txtD         test2.txt[root@v03-svn-client client_webtest]# svn statusD       test2.txt[root@v03-svn-client client_webtest]# lsdefault1.html  default.html  index.html  index.php  test.txt[root@v03-svn-client client_webtest]# svn ci -m "delete test2.txt" test2.txtDeleting       test2.txtCommitted revision 45.

 

[root@v01-svn-test-server online]# pwd/alidata/www/online[root@v01-svn-test-server online]# lsdefault1.html  default.html  index.html  index.php  test.txt[root@v01-svn-test-server online]# svn status

 

[root@v01-svn-test-server www]# cd localsvn/[root@v01-svn-test-server localsvn]# lsdefault1.html  default.html  index.html  index.php  test.txt

 

[Root @ v01-svn-test-server localsvn] # cat test.txt client submit code to svn service update code --- "1 [root @ v01-svn-test-server localsvn] # svn status? Test.txt

 

[Root @ v03-svn-client client_webtest] # cat test.txt client submit code to svn service update code --- "1 [root @ v03-svn-client client_webtest] # lsdefault1.html default.html index.html index. php test.txt [root @ v03-svn-client client_webtest] # svn status [root @ v03-svn-client client_webtest] # echo "Update code ----" 2 "> test.txt [root @ v03-svn-client client_webtest] # svn statusM test.txt [root @ v03-svn-client client_webtest] # svn ci-m "echo 'Update code ----" 2 '> test.txt "Sending test.txt Transmitting file data. committed revision 46. [root @ v03-svn-client client_webtest] # svn status [root @ v03-svn-client client_webtest] #

 

[Root @ v01-svn-test-server online] # pwd/alidata/www/online [root @ v01-svn-test-server online] # lsdefault1.html default.html index.html index. php test.txt [root @ v01-svn-test-server online] # svn status [root @ v01-svn-test-server online] # cat test.txt Client client submit code to svn service update code --- "1 update code ----" 2 [root @ v01-svn-test-server online] #

The svn hook script in the online official environment:

[root@v02-svn-online ~]# cat /svn/webtest/hooks/post-commitREPOS="$1"REV="$2"SVN=/usr/bin/svnWEB=/alidata/www/webtestLOG=/alidata/log/svn/svn.logexport LANG=en_US.UTF-8$SVN update $WEB --username user001 --password 123 >>$LOG#mailer.py commit "$REPOS" "$REV" /path/to/mailer.conf

(Do not disable the firewall unless it is configured !)

[Root @ v01-svn-test-server localsvn] # pwd/alidata/www/localsvn [root @ v01-svn-test-server localsvn] # lsdefault1.html default.html index.html index. php test.txt [root @ v01-svn-test-server localsvn] # svn status? Test.txt [root @ v01-svn-test-server localsvn] # cat test.txt client submit code to svn service update code --- "1 update code ----" 2 [root @ v01-svn-test-server localsvn] # svn add test.txt A test.txt [root @ v01-svn-test-server localsvn] # svn ci-m "timed network cable on the release code" test.txt svn: commit failed (details follow): svn: Can't connect to host '192. 168.1.65 ': No route to host (because the fire Please port did not open) [root @ v01-svn-test-server localsvn] # svn ci-m "scheduled network cable to publish the code" test.txt Adding test.txt Transmitting file data. committed revision 30.

 

[Root @ v02-svn-online webtest] # pwd/alidata/www/webtest [root @ v02-svn-online webtest] # lsdefault1.html default.html index.html index. php test.txt xxxzz.tar xxzz.zip [root @ v02-svn-online webtest] # cat test.txt Client client submit code to the svn service to update the code --- "1 update code ----" 2 [root @ v02-svn-online webtest] # online successful!

 

[Root @ v03-svn-client client_webtest] # echo "Update -----" 3 "> test.txt [root @ v03-svn-client client_webtest] # svn statusM test.txt [root @ v03-svn-client client_webtest] # cat test.txt update ----- 3 [root @ v03-svn-client client_webtest] #

 

[Root @ v03-svn-client client_webtest] # svn ci-m "echo" Update ----- "3"> test.txt "Sending test.txt Transmitting file data. Committed revision 47. [root @ v03-svn-client client_webtest] #

 

[Root @ v01-svn-test-server online] # svn status [root @ v01-svn-test-server online] # lsdefault1.html default.html index.html index. php test.txt [root @ v01-svn-test-server online] # cat test.txt update ----- "3 [root @ v01-svn-test-server online] #

 

[Root @ v01-svn-test-server localsvn] # pwd/alidata/www/localsvn [root @ v01-svn-test-server localsvn] # lsdefault1.html default.html index.html index. php test.txt [root @ v01-svn-test-server localsvn] # svn statusM test.txt [root @ v01-svn-test-server localsvn] # cat test.txt update ----- "3 [root @ v01-svn-test-server localsvn] #

 

[Root @ v01-svn-test-server localsvn] # svn ci-m "Update -----" 3 test.txt "test.txt Sending test.txt Transmitting file data. Committed revision 31. [root @ v01-svn-test-server localsvn] #

 

[Root @ v02-svn-online webtest] # cat test.txt update ----- "3 [root @ v02-svn-online webtest] #

Rollback code:

[Root @ v01-svn-test-server localsvn] # svn diff-r 31: 30 Index: test.txt =================================================== ===========================--- test.txt (revision 31) +++ test.txt (revision 30) @-1 + 1, 3 @-update ----- 3 + client submits code to svn service + update code --- "1 + update code ----" 2

 

[Root @ v01-svn-test-server localsvn] # svn diff-r 31: 30 test.txt Index: test.txt =================================================== ===========================--- test.txt (revision 31) +++ test.txt (revision 30) @-1 + 1, 3 @-update ----- "3 + client submit code to svn service + update code ---" 1 + update code ---- "2 [root @ v01-svn-test-server localsvn] # svn-r 31: 30 "" test.txt

 

[Root @ v01-svn-test-server localsvn] # svn merge-r31: 30 "" svn: Cannot reverse-merge a range from a path's own histure history; try updating first [root @ v01-svn-test-server localsvn] # svn upAt revision 31. [root @ v01-svn-test-server localsvn] # svn merge-r31: 30 "" --- Reverse-merging r31 '. ': U test.txt [root @ v01-svn-test-server localsvn] # cat test.txt client submit code to svn service update code --- "1 update code ----" 2 [root @ v01-svn-test-server localsvn] # svn log-v test.txt ------------------------------------------------------------------------ r31 | user001 | 11:57:52 + 0800 (Thu, 19 May 2016) | 1 lineChanged paths: M/test.txt update ----- "3 test.txt updated r30 | user001 | 11:38:30 + 0800 (Thu, 19 May 2016) | 1 lineChanged paths: a/test.txt "scheduled network cable release code" -------------------------------------------------------------------------- [root @ v01-svn-test-server localsvn] #

 

[root@v01-svn-test-server localsvn]# svn ci -m "merge -r31:30" test.txt Sending        test.txtTransmitting file data .Committed revision 32.

 

[Root @ v02-svn-online webtest] # cat test.txt Client client submit code to svn service update code --- "1 update code ----" 2 [root @ v02-svn-online webtest] # svn log test.txt login r32 | user001 | 13:27:47 + 0800 (Thu, 19 May 2016) | 1 linemerge-r31: 30 ---------------------------------------------------------------------- r31 | user001 | 11:57:52 + 0800 (Thu, 19 May 2016) | 1 line update ----- "3 test.txt -------------------------------------------------------------------------- r30 | user001 | 11:38:30 + 0800 (Thu, 19 May 2016) | 1 line "scheduled network cable release code" -------------------------------------------------------------------------- [root @ v02-svn-online webtest] # rollback successful!

 

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.