Dave Harris

General ramlings about Java

SVN Dump Parts of a Repository August 5, 2008

Filed under: How-to — daveharris @ 5:02 pm

Today at work at Fronde I needed to create a dump of a ‘project’ inside a repository.  Our SVN setup is to have one repo per team and then within there have a folder for each client/project.  In this case I was providing the backup to a client so it was vital that I gave them just their code and not the whole repo.

So my SVN repo was like this:

/
  teamA
    clientA
    clientB
  teamB
    clientC

To dump the clientA history into a portable, re-creatable format, I used svnadmin dump, like this:

svnadmin dump [path to repo] > C:\Repo.svn-dump

Which creates a dump of the entire repository at C:\Repo.svn-dump.  This took about 10 mins with 1000 versions and used 100% so it would be best to perform this outside of normal work hours.  You have been warned!

I then used svndumpfilter (tutorial) to filter just for the ClientA folder (see folder tree above):

svndumpfilter include ClientA < Repo.bak > ClientA.bak

This didn’t take very long and at the end I had a full svn repository that could be re-created anywhere.  To prove the point I installed SVN on my mac and created the repository.  I then loaded the dump file into it and it worked beautifully ;)

svnadmin create /Users/Dave/ClientA
svnadmin load /Users/Dave/ClientA < ClientA.bak
mkdir /Users/Dave/ClientA-checkout
svn co file:///Users/Dave/ClientA clientA-checkout/

Now that you have checked it, you can delete the whole repo backup file (mine was massive) Repo.svn-dump in my case.

Easy as pie once you know how.  The fact that you can’t specify the filter at dump-time is non-intutative, clunky and frankly a waste of space.  However if you only need to do it once it works and produces a very nice result.  Open Source and Open Standards FTW ;)

 

One Response to “SVN Dump Parts of a Repository”

  1. jedsoane Says:

    While I admit it would be more convenient to be able to filter at dump time you can achieve the same outcome using the magic of unix pipes:

    svnadmin dump [path to repo] | svndumpfilter include ClientA > ClientA.bak


Leave a Reply