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-revprop-change 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 DEST_URL

(Note: "DEST_URL" is the url 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.

  • (Updated 04/07/2009: Updated the syntax to reflect the new svnsync usage pattern.)
  • (Updated 04/14/2009: Updated typo.)

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

how about if a user commits

how about if a user commits a change to a past revision number? will svnsync take care of re-sync?

You don't commit to past

You don't commit to past revisions in Subversion. You can change the revision properties, in which you should probably push that revision property change to the mirrored server. Since svnsync works on revision changes, changing a revision property would not be "caught" by svnsync meaning you'll need to do this manually with a post-revprop-change hook.

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.

Hi , thank you for sharing

Hi , thank you for sharing the informations.

--------------------------------------------------
The Servis Of ULudag University Magazine.
by chat and sohbet

This is really an excellent

This is really an excellent article..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..
regards,
esprit

If you look closely at

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.

You can change the revision

You can change the revision properties, in which you should probably push that revision property change to the mirrored server. Since svnsync works on revision changes, changing a revision property would not be "caught" by svnsync meaning you'll need to do this manually Strategy Games

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.

an excellent examination of

an excellent examination of Clone Remote Subversion Repositories.

thanks for information.

thanks for information.

Thank you for laying out the

Thank you for laying out the process to start with svnsync. I think it should be documented as a common use case to use subversion (for example for offline usage.)

I want to make a Repository

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.

I'd love to help but I will

I'd love to help but I will need a little more information on what you mean. Do you want to create a new version control system with .NET and SQL Server or do you want to create a Subversion repository for a project that's using .NET and SQL Server? Give me more information and I'll do my best to help.

how about if a user commits

how about if a user commits a change to a past revision number? will svnsync take care of re-sync?

Good question. Well, the

Good question. Well, the only thing you can do to an "old" revision number is update its revision properties, like log message. In that case, you'd probably want a hook that mirrors the revision property change to the mirror.

This is really an excellent

This is really an excellent article..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.