Clone Remote Subversion Repositories With svnsync

Have you ever needed to easily create a backup/clone of a remote Subversion repository? It sure would be simple if it were local because you could just create a filesystem copy and go about your business. What makes the story worse is when you don't have physical access to the server where the repository is located. This problem usually means filing issues, making support calls, talking to operations or whatever steps you have to take to get the powers that be to create a dump file, or an archive of the filesystem, and post it somewhere to download it. Sometimes this is not a big deal but for others, it can be quite difficult. Well, Subversion actually ships with a nifty little utility to give you the ability to backup/clone any remote repository that you can read.
svnsync became part of the standard Subversion distribution back when 1.4 was released. Designed to easily create and automate the management of mirror repositories, svnsync became a staple for those wanting easy, automatic and readily-available off-site backup. Using svnsync, you could populate all repository changes, as they occur, to a fully-configured Subversion server at a different location ready for a failure. With svnsync, companies were able to make Subversion failover a non-issue. But our focus on svnsync today is for a different purpose.
If you look closely at svnsync's usage patterns, it operates on urls. This means there is no requirement reason that you have to have physical access to the repository to run svnsync against it. Reading this should make a light bulb go off in your head because, "Yes", that means you can run svnsync to create a duplicate of any remote repository to which you have read access. No more filing internal tickets to get your repository clone. No more having to work through your hosting company's support lines to get a duplicate so you can test some new Subversion log parsing tool. The reasons behind needing/wanting a clone of a repository are endless. For a simple list of steps to utilize this information, please look below:

* Create your local repository: svnadmin create PATH
* Create an empty pre-revprop-change hook script: echo "#!/bin/bash" > PATH/hooks/pre-revprop-change
* Make the pre-commit-hook script executable: chmod +x PATH/hooks/pre-revprop-change
* Initialize svnsync: svnsync init file:⁄⁄⁄PATH URL_TO_REPO_ROOT_TO_CLONE
* Synchronize: svnsync sync PATH

(Note: "PATH" is the full filesystem path to the Subversion repository you created in step 1.)
It's that simple. While I know I'm not the first to come up with this usage scenario for svnsync, I do find it quite fascinating and can only imagine how many times it would had saved me time in the past had I only remembered to use it. Now when you need a "dump file" and you do not have physical access to the Subversion server to create one yourself, use the steps above to create a repository clone locally and create your own dump file.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

I was realy relaxed through

I was realy relaxed through you site. But i am a fresher to this industry. i want to make a Repository system using .net 2.0 and Sql Server 2005. Can you just help me out with your suggestions for further proceedings. it would be very great of you.

Waiting................

Thank You! I have been using

Thank You!

I have been using a third part service and could not get a dump of my repository. This is EXACTLY what I needed.

I'm not sure where to begin

I'm not sure where to begin Manash. You have not given any details on what you need. Can we talk about this offline? I would post my email but I'm not into getting more spam than I already do. Send me a private message via irc on irc.freenode.net. My nick is 'jeremyw'.

I have been using a third

I have been using a third part service and could not get a dump of my repository. This is EXACTLY what I needed.

you forgot the inelegant

you forgot the inelegant process of svnsync. how about if a user commits a change to a past revision number? will svnsync take care of re-sync?

Thank you very much for this

Thank you very much for this useful article and the comments. I love this site as it contains good materials.

Regards