Main steps of configuring SVN replication on Linux



Note: This is tested in CentOS 5.5
Considering master SVN has already setup and configured with Apache web server.

1)      Install SVN (slave)
yum install mod_dav_svn subversion

2)      Configure with Apache web server
           
shell>cd /etc/httpd/conf.d/
shell>vim subversion.conf

# Make sure you uncomment the following if they are commented out
LoadModule dav_svn_module     modules/mod_dav_svn.so
LoadModule authz_svn_module   modules/mod_authz_svn.so


# Add the following to allow a basic authentication and point Apache to where the actual
# repository resides.

<Location /repos>
        DAV svn
        SVNPath /var/www/svn/repos
        AuthType Basic
        AuthName "Subversion repos"
        AuthUserFile /etc/svn-auth-conf
        Require valid-user
</Location>

3)      Adding SVN  users

shell> htpasswd -cm /etc/svn-auth-conf yourusername
New password:
Re-type new password:

shell> htpasswd -m /etc/svn-auth-conf anotherusername
New password:
Re-type new password:

4)      Configure repository

shell> cd /var/www/
shell> mkdir svn
shell> cd svn
shell> svnadmin create repos
shell> chown -R apache.apache repos
shell> service httpd restart



    5)   Make mirror repository (slave) revision properties modifiable by synchronizing user
                   (Considering synchronizing user as “svnmirror”)

shell>  cd /var/www/svn/repos/hooks
shell>  vi pre-revprop-change    

Mirror repository's pre-revprop-change hook script

#!/bin/sh
USER="$3"

if [ "$USER" = "svnmirror" ]; then exit 0; fi
echo "Only the svnmirror user may change revision properties" >&2
exit 1

shell> chmod 777  pre-revprop-change



6)     Create subversion access control (Only svnmirror user has write access )

shell>  cd /var/www/svn/repos/hooks
shell>  vi start-commit

Mirror repository's start-commit hook script

#!/bin/sh
USER="$2"

if [ "$USER" = " svnmirror" ]; then exit 0; fi
echo "Only the svnmirror user may commit new revisions" >&2
exit 1

shell> chmod 777 start-commit








7)      Register mirror repository for synchronization  and initial synchronization

svnsync initialize   file:///var/www/svn/repos http://sourceURL/svn/oop  --sync-username svnmirror --sync-password svnmirror123

svnsync synchronize  file:///var/www/svn/repos  --sync-username svnmirror --sync-password svnmirror123 >/var/log/svnsync/svnsyncdata.log



8)  Configure Cron job to synchronize master and slave (mirror) in every 5 minutes.

*/5 * * * * root svnsync synchronize  file:///var/www/svn/repos  --sync-username svnmirror --sync-password svnmirror123 >/var/log/svnsync/svnsyncdata.log














1 comment: