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 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

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

7 thoughts on “Making a local mirror of a subversion repository: using svnsync

    • @Valentin

      No, He is right. What if the $COPY variable equal to something like /svn/project.
      Here if you mention file:///$COPY it become four slashes like file:////svn/project(wrong one).

  1. 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: Logo

You are commenting using your 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