Svn combined with rsync code Publishing System

Source: Internet
Author: User
Tags inotify php online svn update

Svn combined with rsync code Publishing System

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_webtest
Authentication realm: <svn: // 192.168.1.35: 3690> 18ab87c6-8455-4154-a313-7b6fd3775a73
Password for 'root ':
Authentication realm: <svn: // 192.168.1.35: 3690> 18ab87c6-8455-4154-a313-7b6fd3775a73
Username: svnadmin
Password for 'svnadmin ':
Authentication realm: <svn: // 192.168.1.35: 3690> 18ab87c6-8455-4154-a313-7b6fd3775a73
Username: user01
Password for 'user01 ':
 
-----------------------------------------------------------------------
ATTENTION! Your password for authentication realm:
 
<Svn: // 192.168.1.35: 3690> 18ab87c6-8455-4154-a313-7b6fd3775a73
 
Can only be stored to disk unencrypted! You are advised to configure
Your system so that Subversion can store passwords encrypted, if
Possible. See the documentation for details.
 
You can avoid future appearances of this warning by setting the value
Of the 'store-plaintext-password' option to either 'yes' or 'no' in
'/Root/. subversion/servers '.
-----------------------------------------------------------------------
Store password unencrypted (yes/no )? Yes
A client_webtest/default.html
A client_webtest/default1.html
A client_webtest/k.txt
A client_webtest/index.html
A client_webtest/index. php
Checked out revision 40.

[Root @ v03-svn-client ~] # Tree client_webtest/
Client_webtest/
── Defa1.html
── Default.html
── Index.html
── Index. php
── K.txt
 
0 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] # ls
Authz index. php online phpwind rsync_test.sh webtest
Index.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] # ls
Post-commit post-unlock.tmpl pre-unlock.tmpl
Post-commit.tmpl pre-commit.tmpl start-commit.tmpl
Post-lock.tmpl pre-lock.tmpl
Post-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-commit
REPOS = "$1"
REV = "$2"
SVN =/usr/bin/svn
LOCALSVN =/alidata/www/localsvn
WEB =/alidata/www/online
RSYNC =/usr/bin/rsync
LOG =/alidata/log/svn. log
Export LANG = en_US.UTF-8
$ SVN update $ WEB -- username user01 -- password 123
If [$? = 0]; then
Echo ""> $ LOG
Echo 'date'> $ LOG
Echo "#############################"> $ LOG
$ RSYNC-vr -- exclude = ". svn" -- delete $ WEB/$ LOCALSVN> $ LOG
Fi
# 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 submits code to svn service"> test.txt
[Root @ v03-svn-client client_webtest] # cat test.txt
The 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 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
The 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] # ls
Default1.html default.html index.html index. php test.txt
[Root @ v01-svn-test-server localsvn] # cat test.txt
The client submits code to the svn service.
[Root @ v01-svn-test-server localsvn] # svn status
? Test.txt
# Code Synchronization Through rsync-vr -- exclude = ". svn" -- delete/alidata/www/online // alidata/www/localsvn

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 verify the new Code test.txt
[Root @ v03-svn-client client_webtest] # svn status
? Test2.txt
M 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 ---" 1 '> test.txt new code test.txt"
Sending test.txt
Adding test2.txt
Transmitting file data ..
Committed revision 44.

 

[Root @ v01-svn-test-server online] # pwd
/Alidata/www/online
[Root @ v01-svn-test-server online] # ls
Default1.html default.html index.html index. php test2.txt test.txt
[Root @ v01-svn-test-server online] # cat test.txt
The client submits code to the svn service.
Update code --- "1
[Root @ v01-svn-test-server online] # svn status
[Root @ v01-svn-test-server online] # code root successful !!!

 

[Root @ v01-svn-test-server localsvn] # pwd
/Alidata/www/localsvn
[Root @ v01-svn-test-server localsvn] # ls
Default1.html default.html index.html index. php test2.txt test.txt
[Root @ v01-svn-test-server localsvn] # cat test.txt
The client submits code to the svn service.
Update code --- "1
[Root @ v01-svn-test-server localsvn] # svn status
? Test2.txt
? Test.txt
# Rsync successful!

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

[Root @ v03-svn-client client_webtest] # ls
Default1.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] # ls
Default1.html default.html index.html index. php test2.txt test.txt
[Root @ v03-svn-client client_webtest] # svn delete test2.txt
D test2.txt
[Root @ v03-svn-client client_webtest] # svn status
D test2.txt
[Root @ v03-svn-client client_webtest] # ls
Default1.html default.html index.html index. php test.txt
[Root @ v03-svn-client client_webtest] # svn ci-m "delete test2.txt" test2.txt
Deleting test2.txt
 
Committed revision 45.

 

[Root @ v01-svn-test-server online] # pwd
/Alidata/www/online
[Root @ v01-svn-test-server online] # ls
Default1.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] # ls
Default1.html default.html index.html index. php test.txt

 

[Root @ v01-svn-test-server localsvn] # cat test.txt
The client submits code to the svn service.
Update code --- "1
[Root @ v01-svn-test-server localsvn] # svn status
? Test.txt

 

[Root @ v03-svn-client client_webtest] # cat test.txt
The client submits code to the svn service.
Update code --- "1
[Root @ v03-svn-client client_webtest] # ls
Default1.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 status
M 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] # ls
Default1.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
The client submits code to the 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-commit
 
REPOS = "$1"
REV = "$2"
SVN =/usr/bin/svn
WEB =/alidata/www/webtest
LOG =/alidata/log/svn. log
Export 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] # ls
Default1.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
The client submits code to the 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 "the code" test.txt
Svn: Commit failed (details follow ):
Svn: Can't connect to host '192. 168.1.65 ': No route to host (because the port is not enabled for fire prevention)
[Root @ v01-svn-test-server localsvn] # svn ci-m "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] # ls
Default1.html default.html index.html index. php test.txt xxxzz.tar xxzz.zip
[Root @ v02-svn-online webtest] # cat test.txt
The client submits code to the svn service.
Update 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 status
M 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] # ls
Default1.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] # ls
Default1.html default.html index.html index. php test.txt
[Root @ v01-svn-test-server localsvn] # svn status
M 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
+ The client submits code to the 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
+ The client submits code to the 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 up
At 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
The client submits code to the 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 line
Changed paths:
M/test.txt
 
Update ----- "3 test.txt
------------------------------------------------------------------------
R30 | user001 | 11:38:30 + 0800 (Thu, 19 May 2016) | 1 line
Changed paths:
A/test.txt
 
"Publish code on the scheduled network cable"
------------------------------------------------------------------------
[Root @ v01-svn-test-server localsvn] #

 

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

 

[Root @ v02-svn-online webtest] # cat test.txt
The client submits code to the svn service.
Update code --- "1
Update code ---- "2
[Root @ v02-svn-online webtest] # svn log test.txt
------------------------------------------------------------------------
R32 | user001 | 13:27:47 + 0800 (Thu, 19 May 2016) | 1 line
 
Merge-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
 
"Publish code on the scheduled network cable"
------------------------------------------------------------------------
[Root @ v02-svn-online webtest] # rollback successful!

RSync for file backup Synchronization

Monitor host files and directories using inotifywait

Using inotify + rsync for Linux File batch update

Inotify-tools + rsync real-time file synchronization installation and configuration

Complete rsync synchronization Configuration

Remote synchronization of Rsync in CentOS 6.5

Differential file comparison and extraction in Linux folders-the use of rsync

Rsync details: click here
Rsync: click here

This article permanently updates the link address:

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.