Wednesday, 21 October 2015

How to Configure a mirror subversion repository


Setup a Subversion Mirror repository :

Assumption :

You already have a source subversion repository configured
CentOS/RedHat

Steps :

Step 1 : Create an empty subversion repository on the destination.

yum install subversion httpd mod_dav_svn

note :

you might want to add a WanDisco repository to your yum configuration as below :

create  wandisco-svn.repo file with below content at /etc/yum.repos.d/:

 [WandiscoSVN]  
 name=Wandisco SVN Repo  
 baseurl=http://opensource.wandisco.com/centos/6/svn-1.8/RPMS/$basearch/  
 enabled=1  
 gpgcheck=0  
once the yum install is complete to create empty repository cd to the path :

cd /svn
svnadmin create repos                        .......repos is the repository path

Step 2: set the apache configuration for miror repository and create auth file :

 <Location />  
  DAV svn  
  SVNPath /svn/repos  
  AuthType Basic  
  AuthName "SVN Repo"  
  AuthUserFile /etc/httpd/conf/svn-auth-conf  
  Require valid-user  
 </Location>  


as the auth type is basic, we will have to create the svn-auth-conf file : 

htpasswd -cm /etc/httpd/conf/svn-auth-conf <username>

this will generate the file : svn-auth-conf which will be used for http authentication of the repository.

Step 3 : setup local file protocol authentication 

You can  set the password and authorization information for the mirror under the conf directory for repository /svn/repos/ : 




Step 4 : Make the mirror repository only writable by sync user : 

[/]
* = r
username = rw
in the authz file


Step 5 : Make Mirror Repository Revision Properties Modifiable by Synchronizing User

To do this, we need to create a pre-revprop-change hook with something similar to the following example, as a shell script:
 #!/bin/sh  
 USER="$3"  
 if [ "$USER" = "syncuser" ]; then exit 0; fi  
 echo "Only the syncuser user may change revision properties as this is a read-only, mirror repository." >&2  
 exit 1  


Step 6 : Initialize the synchronization : 

svnsync init mirror_repo source_repo --source-username=kiodex_integration --source-password=Tea4two\! 

Copied properties for revision 0.

Step 7: Perform Initial Synchronization
To make sure everything is ready and to perform the initial synchronization, on any system, perform the following:
 svnsync synchronize URL_TO_MIRROR_REPO --sync-username=svnsync --sync-password=svnsyncpassword --source-username=sourceusername --source-password=sourcepassword 
If everything synchronized property, you should see some output similar to this:

Committed revision 1.
Copied properties for revision 1.
Committed revision 2.
Copied properties for revision 2.
Committed revision 3.
Copied properties for revision 3.
 Step 8: Automate Synchronization with post-commit Hook
After taking care of initial synchronization all that needs to happen now is to write a script to be ran either as a scheduled process or as a post-commit hook to synchronize your mirror repository with the master repository.  the post-commit hook at the source gives the best option 
add below to your existing post-commit hook : 

svnsync synchronize URL_TO_MIRROR_REPO --sync-username=svnsync --sync-password=svnsyncpassword --source-username=sourceusername --source-password=sourcepassword

No comments:

Post a Comment