Is there a simple way to copy a directory from one repository into another repository with copying all of the history?
-
Possible duplicate of *[How do I move a single folder from one Subversion repository to another repository?](http://stackoverflow.com/questions/417726/how-do-i-move-a-single-folder-from-one-subversion-repository-to-another-reposito)*. – Peter Mortensen Dec 27 '16 at 08:17
-
You can check these questions - [How do I move a single folder from one Subversion repository to another repository?](http://stackoverflow.com/questions/417726) - [Exporting a single project from an SVN repository](http://stackoverflow.com/questions/595718) - [Is it possible to migrate a single file from one SVN repository to another while preserving history?](http://stackoverflow.com/questions/463746) - [How do I dump one project out of an SVN repository which contains multiple projects?](http://stackoverflow.com/questions/337024) - [How can I extract a subtree from my SVN repository into a n – fglez Jun 02 '09 at 14:57
9 Answers
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.

- 30,738
- 21
- 105
- 131

- 28,537
- 15
- 60
- 73
-
23Be careful, I just learned the hard way that svnadmin dump DOES NOT include hooks/ or conf/ – delimiter Dec 07 '11 at 21:23
-
6Just 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. http://stackoverflow.com/questions/8866035/unable-to-do-an-svn-dump-error-e720002-and-format-errors this is a solution for those on a remote location – Chang Hyun Park Dec 24 '13 at 05:36
-
5svnrdump dump and svnrdump load would alow you to dump and laod a repository over the network. – Tobias Kremer Feb 03 '14 at 10:15
-
2A 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](http://stackoverflow.com/questions/267256/combining-multiple-svn-repositories-into-one) – domih Mar 13 '14 at 22:16
-
What If I want to copy multiple folders from one repository to another repository? – Gangadhar Jannu Jan 30 '15 at 15:58
-
You also need to create the destination repository first with `svnadmin create path/to/newrepos`. – Vargas May 16 '17 at 14:13
-
I 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 lose `authz`, `passwd`, `svnserve.conf`? – Jon Weinraub Mar 01 '18 at 14:31
-
-
@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... – JohannesB Sep 12 '18 at 10:01
-
This is not the simplest way. The simplest way is to simply copy the repository directory as is or using the `svnadmin hotcopy` tool. – bahrep Apr 29 '20 at 19:09
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

- 30,738
- 21
- 105
- 131

- 4,620
- 5
- 39
- 54
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:
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.

- 30,738
- 21
- 105
- 131

- 13,132
- 15
- 75
- 92
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
.

- 16,643
- 4
- 81
- 106
I think it should be stated that the dump file created by utilizing
svnadmin dump path/to/repos > dumpfile
can be created (from svn 1.7 and forth) using the command
svnrdump dump url_to_repos > dumpfile
This is useful when done from a remote computer and not the server.

- 349
- 7
- 21
To migrate the repository from one server to another version following are the steps you need to follow.
Step 1: Dump all the repository versions into a dump file. You might be having thousands of versions in the existing repository. So you can create a dump file using the following script.
dump.sh
# Here “i” is the version starting number, and “j” is the maximum version number of your existing #repository.
j=4999;
for ((i=0;i<=$j;i++));
do
# your-unix-command-here
echo $i
svnadmin dump <old_server_repository_location > -r $i –incremental > <dump_location>/$i.dump
done
In the above script you might get a complete dump of the old repository depending on the space availability, or you can take the dump in a short interval (i.e. from 0-5000, then from 5001-10000 and so on).
Step 2: Execute the above script using the below command. Depending on the kernel version you need to execute either of the below two queries.
$ bash dump.sh > stdout.sh
$ ./sh dump.sh > stdout.sh
This will write all the commands you had to execute using the above command into stdout.sh file. You can track this file for your future reference.
Step 3: Check if the firewall is open for port number 22 between the old and the new server. If that is not open, then ask your administrator to make this available.
Step 4: Now copy all the dump files generated from the old SVN repository to the new server using the below command.
$ sftp xxxx@<new_server>
Connecting to <new_server>…
Password:
sftp> mput *.dump <new_server>/dump_location
In the above command, xxxx
is the user who is doing the operation. In the process of doing sftp you are copying the dump files from the old server to the new server.
Step 5: Create a new repository to the new Server
$ svnadmin create <new_repository>
Step 6: Now use the below script to load all the dump files.
load.sh
# Here “i” is the version starting number, and “j” is the maximum version number of your existing #repository.
j=4999;
for ((i=0;i<=$j;i++));
do
# your-unix-command-here
echo $i
svnadmin load –bypass-prop-validation <new_repository> < dump_location /$i.dump
done
Just following the above six simple steps you will be able to migrate your existing repository to a new repository. Through this process you do not need to worry about the corrupted revisions of your existing repository.

- 1
- 1

- 19
In case this helps others, there is svn2svn to replay changesets from one Subversion repository to another:

- 25
- 3