Mirroring CollabNet Subversion Edge Servers

I recently needed to deploy a mirrored instance of a Subversion server which was running the CollabNet Subversion Edge ‘bundled’ version control solution. While researching how to accomplish this, I didn’t come across a howto guide specifically tailored to the CollabNet SubversionEdge product, so I’ve documented my process for mirroring SVN servers in this article. Read on for a step by step guide on how to mirror your own repositories between Subversion Edge servers.


The svnsync tool provides a means to replicate changes made to a master Subversion repository on a secondary mirror repository on a different server. Subversion hook scripts are used to invoke the svnsync tool every time a user commits changes to the master repository. A new Subversion user account will be created to run these synchronisation commands between the two repositories.

This guide assumes that you already have a working Subversion Edge server deployed, with at least one repository set up, and a second (empty) Subversion Edge server ready to be used as the mirror server.

I have written these instructions for Subversion Edge 3.1.2 64-bit on Windows - the general process for Subversion Edge on Linux or Solaris servers is the same, except the hook scripts will need to be altered to run with something like Bash instead of Windows Batch script. These instructions have also been tested to work equally well for the older 2.x versions of CollabNet Subversion Edge.


Note: In the examples below, several variables will be used which you must change to suit your environment. The master server is named master.engineering.mycorp and the mirror server is called mirror.engineering.mycorp. The synchronisation user account used here is svnsync with a password of SYNCPASSWD. The repository being mirrored is called MyRepo.

Configuring the Secondary SVN Server

First, configure the secondary mirror server with a new empty repository and Subversion Edge system user account that has read-write access permissions to it, as follows:

  1. Log in to your Subversion Edge web interface on the mirror server as a user with administrator privileges.
  2. Click the Users link on the top menu and create a new user account called svnsync with the roles ROLE_ADMIN_SYSTEM and ROLE_USER. Assign a password of your choosing to this user (here I will use SYNCPASSWD) as explained above.
  3. Go to the Repositories screen and click the Create button to create a new repository. This will be where the content mirrored from the master server will be synchronised to. Give the new repository the same name as the repository on the master Subversion server that is being mirrored (here I will use MyRepo). Select the Empty Repository Template option and click the Create button.
  4. Click the Access Rules link on the left hand side of the page, and then click the Edit button to modify the repository permissions so that the new svnsync user has read-write access to the new mirror repository. Any other users must only have read access. For further information on Subversion Repository ACL’s refer to Chapter 5 of the SVN Book.
  5. Optionally, go to the Backup Schedule screen and configure automated local backups of the new mirror repository (e.g. a daily hotcopy) as desired. Setting the backup schedule options to match those that are configured on the master repository is probably a good place to start.
  6. Log out from the web interface on the mirror server.

Next, we create a hook script on the mirror server’s filesystem called pre-revprop-change.bat. This file must exist, even if it does nothing, in order for our mirrored repository to accept revision property changes made on the master repository (for example, if someone edits a commit log message after the commit was originally made). A more detailed explanation can be found in the pre-revprop-change.tmpl file that is created by the Subversion Edge installer in the hooks directory.

  1. On the mirror server’s Windows desktop, open an Explorer window and navigate to the CollabNet Subversion Edge installation directory, such as C:\csvn.
  2. Navigate to the data\repositories\MyRepo\hooks\ directory within the installation directory.
  3. Create a new file called pre-revprop-change.bat with the following contents:
    exit 0

Configuring the Master SVN Server

Now we create the necessary hook scripts on the master Subversion server, pre-revprop-change and post-commit. The pre-revprop-change.bat script allows retrospective changes to SVN file properties to be propagated to the mirror repository, while the post-commit.bat script duplicates all commits made on the master server to the mirror server.

  1. On the mirror server’s Windows desktop, open an Explorer window and navigate to the CollabNet Subversion Edge installation directory, such as C:\csvn.
  2. Navigate to the data\repositories\MyRepo\hooks\ directory within the installation directory.
  3. Create a new file called pre-revprop-change.bat with the following contents (script originally sourced from A Dreamer’s Reality blog):

    set repository=%1
    set revision=%2
    set userName=%3
    set propertyName=%4
    set action=%5
    if /I not "%propertyName%" == "svn:log" goto ERROR_PROPNAME
    if /I not "%action%" == "M" goto ERROR_ACTION
    set bIsEmpty=true
    for /f "tokens=*" %%g in ('find /V ""') do (
    set bIsEmpty=false
    if "%bIsEmpty%" == "true" goto ERROR_EMPTYgoto :eof:ERROR_EMPTY
    echo Empty svn:log messages are not allowed.
    echo Only changes to svn:log messages are allowed.
    echo Only modifications to svn:log revision properties are allowed.
    exit /b 1
  4. Create another new file called post-commit.bat with the following contents (change the C:\csvn\ path within the script if applicable):

    C:\csvn\bin\svnsync synchronize http://mirror.engineering.mycorp/svn/MyRepo http://master.engineering.mycorp/svn/MyRepo --username=svnsync --password=SYNCPASSWD

Initializing Mirror Repository

At this stage, the empty mirror repository that was created earlier is ready to be initialized for use by the svnsync tool:

  1. On the mirror server’s Windows desktop, open a Command Prompt window.
  2. Initialize the new mirror repository with the following command:
    svnsync initialize http://mirror/svn/MyRepo http://master/svn/MyRepo --username=svnsync --password=SYNCPASSWD
  3. If the initialize command is successful, message(s) regarding copying properties for revisions will be displayed.

You should now have a duplicate repository operational on the mirror server which contains the same data as the associated repository on the master Subversion server.

Testing the Synchronization

Test the new configuration by committing a change to the repository on the master server as normal, and then inspecting the mirror repository (e.g. with the ViewVC browser tool that comes with CollabNet Subversion Edge) to confirm that the changes were automatically replicated to the mirror.

You may notice the commit process takes longer than normal to complete, the additional delay is largely dependent on the network performance between the master and mirror servers.

Final Steps

You may wish to consider creating an additional system-wide script on the master server which is executed daily by the Task Scheduler (or cron), to ensure that the two repositories maintain their synchronisation even when something unexpected happens (e.g. network failure), as shown in the example below:

call C:\csvn\data\repositories\MyRepo\hooks\post-commit.bat
C:\csvn\bin\svnsync.exe copy-revprops http://mirror.engineering.mycorp/svn/MyRepo http://mirror.engineering.mycorp/svn/MyRepo --source-username=svnsync --source-password=SYNCPASSWD --sync-username=svnsync --sync-password=SYNCPASSWD

From a security perspective, you should ensure unauthorised users cannot access the hook scripts which contain administrator account credentials for the SVN servers (svnsync user), for example via NTFS filesystem permissions.

If you have multiple repositories on the master SVN server which must be mirrored, simply repeat the above process (without creating user accounts again).


If you’re having difficulties, here are a few things to check:

  • Confirm that you correctly created the svnsync user account on the mirror Subversion server: manually check it can login to Subversion and confirm you’re using the correct password in the scripts.
  • Place the occurrences of the password within the scripts inside quotations if it contains any non-alphanumeric characters.
  • If the Subversion binaries are not working from the command line, confirm that the bin directory in your CollabNet installation is present in your system’s PATH environment variable.
  • When creating the mirror repository, make sure that it is completely empty (including no tag, branch, trunk structure) and that no user commits are made to it or the synchronisation will fail.
  • If possible, disable firewalls that sit between the master and mirror servers to confirm security infrastructure is not blocking the synchronisation traffic.

Page last updated: