SVN Dump Parts of a Repository

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] > repo.dump

Which creates a dump of the entire repository into a file called repo.dump.  This took about 10 mins with 1000 versions and used 100% CPU 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.dump > clientA.dump

If you have nested repositories, then it breaks with a syntax error.  To get around this you need to run the dump multiple times using the ‘exclude’ directive until you have what you want:

svndumpfilter exclude clientB < repo.dump >> clientA.dump
svndumpfilter exclude clientC < repo.dump >> clientA.dump

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 😉

This entry was posted in How-to.

4 comments on “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

  2. Brian Lloyd says:

    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

    This part is not entirely true. Considering this site is still one of the top search for filter examples, I thought I would mention this.

    On Unix like systems, a command like

    svnadmin dump [path to repo] | svndumpfilter exclude [first thing to exclude] [second thing to exlude] > svndump.dump

    Even Windows should support this single round of piping output without issues.
    The file put to disk will already have the part you don’t want removed.

    Now, if you are splitting the repository, you might want to dump once and then filter it multiple times, but you don’t have to.

  3. daveharris says:

    You both make a good point, I had not thought of that.
    I now use Git so I don’t need to worry about such annoyances, but good to know my post is top hit and it useful to someone 😉

  4. […] Dump only part of an svn repository This entry was posted in Uncategorized and tagged ssh, svn by hoursofop. Bookmark the permalink. […]

Leave a reply to Dump only part of an svn repository | Hours of Operation Cancel reply