How do I migrate an SVN repository to another SVN repository?
Solution 1
The simplest way is using:
svnadmin dump path/to/repos > repos.out
This will create a portable format for your repository (with history) in the file repos.out
. You can then use
svnadmin load path/to/newrepos < repos.out
to load your 'dumped' repository to the new or existing one.
Chapter 5. Repository Maintenance -> Migrating Repository Data Elsewhere has this note about using svnadmin dump
as of version 1.7:
The Subversion repository dump format describes versioned repository changes only. It will not carry any information about uncommitted transactions, user locks on filesystem paths, repository or server configuration customizations (including hook scripts), and so on.
Solution 2
As suggested in the Subversion book:
svnadmin dump path/to/repos_src \
| svndumpfilter include path/inside/svn/to/directory \
| svnadmin load path/to/repos_dst
With an example:
svnadmin dump /var/lib/svn/old_repo \
| svndumpfilter include trunk/my_project/common_dir \
| svnadmin load /var/lib/svn/new_repo
Solution 3
If you don't want history, you can use svn export
to get a clean folder without the .svn
folders and then svn import
into your other repository.
With history, you would need to use the svnadmin dump
. You would then use svndumpfilter
to filter for only the parts or paths you want to use before using svnadmin load
.
Topics to read:
Solution 4
Use the svnsync
— Subversion Repository Mirroring command:
svnsync
is the Subversion remote repository mirroring tool. Put simply, it allows you to replay the revisions of one repository into another one.
The Subversion documentation for the svnsync
command has the following warning (as of version 1.7) implying that once some other SVN commands are used to modify a mirror repository, svnsync
should not be used with that particular mirror again:
svnsync
is very sensitive to changes made in the mirror repository that weren't made as part of a mirroring operation. To prevent this from happening, it's best if thesvnsync
process is the only process permitted to modify the mirror repository.
Solution 5
In Subversion version 1.7 there is a new command, svnrdump
which can be used to access a remote repository and generate the same dump format output as is generated by the svnadmin dump
command. This allows you to use svnrdump
with svnadmin load
to transfer a Subversion repository.
See svnrdump—Remote Subversion Repository Data Migration which has an explanation of the new command.
In Chapter 5 of the red book, the section Migrating Repository Data Elsewhere has a sub-section Repository data migration using svnrdump
that mentions:
The primary difference [between
svnrdump
andsvnadmin dump
] is that instead of requiring direct access to the repository,svnrdump
operates remotely, using the very same Repository Access (RA) protocols that the Subversion client does. As such, you might need to provide authentication credentials. Also, your remote interations [sic] are subject to any authorization limitations configured on the Subversion server.
I would also assume that the limitations of svnadmin dump
concerning server configuration customizations such as hooks may not be transferred would also apply to svnrdump
.
Jakub Arnold
Experienced software engineer with a background in machine learning and computer science and over 7 years of commercial practice of software development, looking to work on production quality software.
Updated on January 05, 2020Comments
-
Jakub Arnold over 4 years
Is there a simple way to copy a directory from one repository into another repository with copying all of the history?
-
delimiter over 12 yearsBe careful, I just learned the hard way that svnadmin dump DOES NOT include hooks/ or conf/
-
Chang Hyun Park over 10 yearsJust in case anyone makes the mistake I made today, You need to actually be on the svn machine to do this. You can't checkout the repo, and dump from a remote working copy. stackoverflow.com/questions/8866035/… this is a solution for those on a remote location
-
Tobias Kremer over 10 yearssvnrdump dump and svnrdump load would alow you to dump and laod a repository over the network.
-
domih about 10 yearsA somehow safe way to merge is to checkout first via tortoise and add+commit a new folder. Then a svnadmin load --parent-dir newRootFolder < dump.out works for me. See also Combining multiple repositories into one
-
Buddybear over 9 yearsWhat If I want to copy multiple folders from one repository to another repository?
-
Vargas about 7 yearsYou also need to create the destination repository first with
svnadmin create path/to/newrepos
. -
Jon Weinraub about 6 yearsI know this is a few years old now, but I am migrating svn from one server to another, and pretty much have 64 repos in
/home/repos/svn
, so each repo has a conf for access, i would loseauthz
,passwd
,svnserve.conf
? -
Sandburg over 5 yearsWhat about the
svnserve pack
option, isn't it newer and better? -
JohannesB over 5 years@delimiter Is there a solution to this problem or is the current solution to manually copy the folders every time we make a dump? Seems like this is something that can be overlooked way to easily...
-
bahrep about 4 yearsThis is not the simplest way. The simplest way is to simply copy the repository directory as is or using the
svnadmin hotcopy
tool.