Releases after 1.4 in Subversion saw the introduction of a new tool “svnsync” which was very useful in creating two synchronized svn repositories. It can be used on many different designs and the most simplest design was to create a mirrored repository of source repository as a backup. In this article I will describe a scenario where it is one step further on above mentioned design.
Lets assume that a company has two developer locations geographically apart where one location has the main svn repository and other location needs to setup a mirrored repository of the main svn due to limitation on link bandwith between two locations. Remote location developers will use the local mirror to checkouts and updates, and will use the main repository to checkin their code. Therefore the local mirror will act as a read-only repository.
Below I will list down the steps needed in implementing the above scenario.
Create a location for new mirror repository
$ mkdir /var/svn/mirror/subversion
Create new repository in it
$ svnadmin create /var/svn/mirror/subversion/repo-two
Configure the mirror repository to allow revision properties and only the “svnsync” user should be able to do the modifications. This can be achieved by creating a “hooks/pre-revprop-change” file within the mirror repository and granting execution permissions.
#!/bin/sh
if [ “$3” = “svnsync” ]; then exit 0; fi
echo “Only the guest user may edit revision properties through svnsync” >&2
exit 1
There after initialize the repository
svnsync init --username svnsync file:///var/svn/mirror/subversion/repo-two https://svn.example.com/svn/repo-one
Use the ” svnsync sync” command to populate the mirror repository,
svnsync sync file:///var/svn/mirror/subversion/repo-two
To keep both mirrors syncronized, you can schedule the above command to run periodically ( Cron Jobs).
One thought on “How to setup a Mirrored Subversion repository”