Common problems: a repository in on server A and needs to be migrated onto server B; a single repository needs to be spit into few separate ones; what to do with local working copies after server migration; the repository storage method needs to be changes e.g. from berkleyDB to file-system.

In some simple cases the repository can be moved directly on file system level. However, the following steps describes a more complex case, in a generally applicable way: a migration and split of repositories from one server to another, fixing the local working copies. Assume this situation:

ServerA, repository: projects  path: /proj1
                            path: /proj2

->

ServerB: repository: proj1     path: /
ServerB: repository: proj2     path: /

For example: https://svn.server.com/projects/proj1 -> https://mysvn.com/proj1

1. Export the repository on ServerA
svnadmin dump /path/to/repos/projects > projects.dump

2. Split / filter out repositories
svndumpfilter include proj1 < projects.dump > proj1.dump
svndumpfilter include proj2 < projects.dump > proj2.dump

3. Fix the paths
As the dump is in a text format you can easily edit it to change prune the projects root directory. You do it:

  1. by renaming the paths:
    sed -e "s/Node-path: projects\//Node path: /" < proj1.dump > proj1-fixed.dump
    The same for proj2.dump
  2. and removing the section that creates the root directory, i.e. delete the following lines form somewhere at the beginning of both dumps proj1-fix.dump and proj2-fix.dump:
    Node-path: projects
    Node-action: add
    Node-kind: dir
    Prop-content-length: 10
    Content-length: 10

    PROPS-END

4. Import the repositories on Server
Create a new repository for each project and import the dumps. (A detailed description of how to setup a Subversion (and friends) is in my previous post)

svnadmin create /path/to/repos/proj1
svnadmin load /path/to/repos/proj1 < proj1-fixed.dump

Do it analogically also for proj2.

Done
Happy checkout :) After migration you’d rather check/modify/recreate the hooks, users for authentication (if you used some of those). And again, read the official SVNBook for details.

Fixing existing working copies
If you don’t want to checkout but rather continue using existing working copies you can (cannot be done in case of some repository splits).

First of all, use --force-uuid option for svnadmin load (step 4). Then you can tweak the local copy by running (in the root of the local repo):
svn switch --relocate http://ServerA/testproject https://ServerB/project .



6 Responses to “Subversion: move, migrate, split”  

  1. 1 Colin McCormack

    Thanks! Concise, accurate, to the point, and *very* helpful.

  2. 2 Thiago Lima

    It’s a very good step-by-step, but I got some problems when trying to fix the paths in my dump. Does this tip works well with binary dumps? Cos’ I have some binary files in my repository…

    thanks

  3. 3 Caleb Cranford

    This post helped me with binary files in the dump:
    http://blog.fredrikbostrom.net/?p=40

  4. 4 viz

    If you do a simple migration of Repository, just do the three steps:

    on SourceServer:
    svnadmin dump PATH_TO_REPOS_1 | gzip > dumpfile.gz

    on DestinationServer:
    gunzip -c dumpfile.gz | svnadmin load --force-uuid PATH_TO_REPOS_2

    on Client:
    svn switch --relocate ORIGINAL_ROOT NEW_ROOT .

  5. 5 Jakob Kruse

    Very nice description. Worked like a charm!

    Thank you!

  6. 6 Jonathan Stanton

    Instead of
    sed -e “s/Node-path: projects\//Node path: /” proj1-fixed.dump
    use
    sed -e “s/-path: projects\//-path: /” proj1-fixed.dump

Leave a Reply