Readonly Subversion/Git mirror with SubGit and svnsync

Recently we were given a task to create a readonly Git mirror of a Subversion repository. We’ve used SubGit and svnsync to accomplish this task, all went pretty smooth and I’ve decided to publish a small HOWTO on that topic.

1. Create empty Subversion repository. This will be a readonly “slave” of the original Subversion repository:

$ svnadmin create slave

2. Enable pre-revprop-change hook in the slave repository. This is needed to make svnsync work:

$ nano slave/hooks/pre-revprop-change

exit 0

Do not forget to make hook script executable:

$ chmod +x slave/hooks/pre-revprop-change

3. Synchronize slave repository with the master one using svnsync (see topic on replication with svnsync in Subversion Book):

$ svnsync initialize file://home/user/slave http://host/svn/master
$ svnsync synchronize file://home/user/slave

4. Install SubGit into the slave repository, to add Git part (see SubGit Book for more details):

$ subgit configure slave

At this point you may increase idleTimeout setting for SubGit background translation process.
Edit slave/conf/subgit.conf file:

# value is in seconds
idleTimeout = 300

Higher timeout value will allow subgit translation process to be reused between svnsync scheduled invocations.

$ subgit install slave

At this point, Git repository (or multiple repositories) is created. User may access it, e.g. over SSH:

$ git clone ssh://user@slave-host/home/user/slave slave

5. Schedule svnsync runs to enable replication of the new revisions. SubGit will ensure that these revisions are translated to the Git repository too!

$ crontab -e

# m h dom mon dow command
3 * * * * svnsync file:///home/user/slave

svnsync will fetch new revision from the remote repository and SubGit will translate them into Git.

If you’ve followed the steps above you have created a readonly Subversion and Git mirrors of Subversion repository at http://host/repos/master
Both Subversion and Git mirrors resides at /home/user/slave directory.

6 thoughts on “Readonly Subversion/Git mirror with SubGit and svnsync

  1. Hello everyone, it’s my first go to see at this site, and post is really fruitful designed for me,
    keep up posting these types of articles.

  2. You actually make it appear really easy along with your presentation however I
    find this topic to be actually something which I believe
    I’d by no means understand. It sort of feels too complex and extremely large for me.
    I am looking ahead to your subsequent put up, I’ll
    try to get the hold of it!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>