Moving a subversion repository from one server to another, while still preserving all your version history may seam like a daunting task, but fortunately it's not too difficult.
I recently had to move a subversion (svn) repository to another server. The repository was on a Windows server and had to be moved to another, the old repository looks like below:
#repositories
--repository
----branch
----tags
----trunk
--------projects
----------calc/
----------cal/
----------spreadsheet/
Now I want to move each project into separate repository, looks like below:
#repositories
--CalcRepository
----branch
----tags
----trunk
--CalRepository
----branch
----tags
----trunk
--SpreadsheetRepository
----branch
----tags
----trunk
Step 1: Backup your old Repository
The first thing you need when moving from one server to another is a dump of your subversion repository. Hopefully you are already creating dump's with a backup script, but if not here's how you can create a subversion dump file:
$ svnadmin dump D:\Repositories\repository > D:\svn_backup\all_repo.dump
Use the --revision (-r) option to specify a single revision, or a range of revisions, to dump. If you omit this option, all the existing repository revisions will be dumped.
$ svnadmin dump myrepos -r 23 > rev-23.dumpfile
$ svnadmin dump myrepos -r 100:200 > revs-100-200.dumpfile
STEP 2: FILTER FOLDER FROM DUMP FILE
$ svndumpfilter include
trunk/projects/calc < D:\svn_backup\all_repo.dump >
D:\svn_backup\calc.dump
$ svndumpfilter include
trunk/projects/cal < D:\svn_backup\all_repo.dump > D:\svn_backup\cal.dump
$ svndumpfilter include
trunk/projects/spreadsheet < D:\svn_backup\all_repo.dump >
D:\svn_backup\spreadsheet.dump
At
this point, you have to make a decision. Each of your dump files will create a
valid repository, but will preserve the paths exactly as they
were in the original repository. This Repository Administration means that even
though you would have a repository solely for your calc project, that
repository would still have a top-level directory named calc. If you want your trunk, tags, and branches directories to live in the root of your repository, you
might wish to edit your dump files, tweaking the Node-path and Node-copyfrom-path headers so that they no longer
have that first calc/ path component. Also, you'll want to remove the section
of dump data that creates the
calc directory. It will look something like the following:
Node-path: /trunk/projects/calc => /trunk
Node-copyfrom-path:
/trunk/projects/calc
=> /trunk
The dump file contains all the revisions you have ever
made to your svn repository, so it will probably be quite large (it even
includes files you may have deleted in a previous revision).
Step 3: Create the new Repository
Now, simply transfer the dump file on to your new
subversion server, and create an empty repository:
$ svnadmin create D:\Repositories\CalcRepository
$ svnadmin create D:\Repositories\CalRepository
$ svnadmin create
D:\Repositories\SpreadSheetRepository
Step 4: Import your old repository
into the new one
Next import your dump file:
$ svnadmin load CalcRepository < D:\svn_backup\calc.dump
$ svnadmin load CalRepository < D:\svn_backup\calc.dump
$ svnadmin load SpreadsheetRepository < D:\svn_backup\Spreadsheet.dump