Making a local mirror of a subversion repository: using svnsync

For various reasons, it may be good to have a mirror of a given svn repository (by mirror, I mean a full copy of all the history), for example to have faster access to the history if you have slow connection, or, as in my case, to enable simpler import to other source control systems (bzr, hg, etc…). Subversion comes with a tool, svnsync, but there is not much documentation on it, and the one I found was not accurate, or at least did not work for me. So here are a the exact steps which made it work for me, on Ubuntu (7.10, but I don’t think the version matters as long as you have svnsync and a relatively recent subversion client).

I will assume for the rest of this mini-tutorial that the repository you want to copy is ORIG (which should point to a valid svn repository, for example http://svn.scipy.org/svn/numpy. Note that it must be the repository URL, not trunk or anything), and the one to copy is COPY (this one will be a pathname). The first thing to do is to create a local subversion repository on your machine:

svnadmin create $COPY

Check that you create correctly the repository at the right path:

svn info file://$COPY

Now, create the following hook into the mirror repository: $COPY/hooks/pre-revprop-change, and put the following content into it

#!/bin/sh
USER="$3"
if [ "$USER" = "svnsync" ]; then exit 0; fi
echo "Only the svnsync user can change revprops" >&2
exit 1

This is so that only the svnsync user canĀ  modify the revprops, which is necessary for the mirror. The file must be executable:

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

Now, you can initialize the synchronisation (e.g. the mirroring):

svnsync init --username svnsync file://$COPY $ORIG

If successfull, it should tell you something like ” Copied properties for revision 0″. You can now start the mirroring (which will take time, depending on your network connection, and the size of the repository of course).

svnsync sync file://$COPY
About these ads

7 responses to “Making a local mirror of a subversion repository: using svnsync

  1. Thanks man, this helped me a lot.

  2. ptg21

    Very helpful, and easy to follow. Thanks very much.

  3. Is it possible to make a mirror readonly and somehow to write to master repository ?
    Thanks !

  4. You actually should do the followign steps:

    It’s not file://$COPY. instead file:///$COPY see 3 slashes!

  5. This procedure creates an empty mirror – do we still need to do a checkout to populate the mirror with the actual files? If so – at which point in the process? The very end? Thanks…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

December 2007
M T W T F S S
« Nov   Jan »
 12
3456789
10111213141516
17181920212223
24252627282930
31  

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 9 other followers

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: