Copy a project from SVN repository to another

Sometimes I program some stuff at home but I need it later on my work office. It is necessary to move the project from my private SVN repository to the work repository. I need all the revisions, not only the latest one.

First at all, I have to dump the project at home:

# svnadmin dump path/to/home/svn > repository.dmp

The path/to/home/svn must be a local path, so you have to work on the repository machine (you cannot use svn+ssh etc.). The dump contains now the whole repository, all revisions. So it can be huge. To filter the relevant project there is a tool called svndumpfilter.

# cat repository.dmp | svndumpfilter --drop-empty-revs --renumber-revs include /path/name_of_the_project/in/svn > project.dmp

You have to use the case-sensitive project name (inclusive the parent folder names within SVN). Now copy the project.dmp to the SVN repository server on your work office. Again you have to work on the repository machine to use a local file path.

To load the project use:

# svnadmin load --ignore-uuid /path/to/work/svn < project.dmp

This will import the project on the root folder / of the repository. It contains all the folders and subfolders of the source repository, where the project was located there. So if your original project path was

/projects/webobjects/example

the destination path will be

/projects/webobjects/example

too. To prevent overwriting existing stuff, you can use the --parent-dir switch during the load operation:

# svnadmin load --ignore-uuid --parent-dir /projects/phosco/examples /path/to/work/svn < project.dmp

So the resulting path will be

/projects/phosco/examples/projects/webobjects/example

You have to move the imported project on the right position later. If you have tested the command above, you have seen an error. This is a problem of the source folder of the project, it doesn’t exist on the destination repository. Before you can load the project dump, you have to create the base folder:

svn mkdir -m "Creating new project layout." file:///path/to/work/svn/projects/phosco/examples/projects

You have to use an URI to access the repository with svn. You cannot use the local path as with svnadmin. It is necessary to create only the first component of the project path (not the deeper subfolders):

Location on the source SVN:
/projects/webobjects/example

Build on the destination SVN:
projects

Together with the parent-dir of the destination repository you have to create a folder
/projects/phosco/examples/projects

Now you can load the project into the destination repository:

# svnadmin load --ignore-uuid --parent-dir /projects/phosco/examples /path/to/work/svn < project.dmp

The last step it the move of the newly imported project to the correct place within the destination repository:

svn move -m "move the imported project to the right location" file:///path/to/work/svn/projects/phosco/examples/projects/webobjects/example file:///path/to/work/svn/projects/phosco/examples/new-example

Leave a Reply