Replicating a remote SVN repository to a new server repository using svnsync

    Here are some simple and straight-forward steps that you can take to backup, sync or otherwise copy the entire subversion repository from one server to another for any reason. In my case, I am in the process of reorganising my servers and I need to move the subversion repositories to a redundant setup from a dedicated single-hardware server. The following steps are not revolutionary or unique (there are many SVN manuals and sites detailing some version of these steps). I am documenting the process as I have run it to make life easier for the next person that just needs to replicate a live repository from one server to another.

    I should note that in order to avoid unfaithful copies, you should suspend all modifications to the source repository while you do this to ensure that changes do not take place while you are sync'ing.

    1. Create a new repository on the destination server in a directory of your choice
      cd /some/path
      mkdir newrepositoryplace
      svnadmin create newrepositoryplace/reponame
    2. To avoid having to type long paths, we will create a variable to carry the path to our new repository
      mynewrepository=/some/path/newrepositoryplace/reponame
    3. Now, we need to prepare the new repository to receive new changes
      echo '#!/bin/sh' > $mynewrepository/hooks/pre-revprop-change
      chmod +x $mynewrepository/hooks/pre-revprop-change
    4. The we initialise the source destination and source repository paths
    5. Begin the synching process - will run through all the revisions ever made to the source repo and mirror them to the new server
      svnsync sync file://$mynewrepository

    The last command will trigger a replication of each committed version from the source to the destination server repositories