How do I migrate an SVN repository to another SVN repository?
Asked Answered
H

9

63

Is there a simple way to copy a directory from one repository into another repository with copying all of the history?

Henryson answered 2/6, 2009 at 14:43 Comment(2)
O
80

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.

Outbuilding answered 2/6, 2009 at 14:48 Comment(10)
Be careful, I just learned the hard way that svnadmin dump DOES NOT include hooks/ or conf/Hadden
Just 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. #8866535 this is a solution for those on a remote locationBurnight
svnrdump dump and svnrdump load would alow you to dump and laod a repository over the network.Pannell
A 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 oneApocynaceous
What If I want to copy multiple folders from one repository to another repository?Andriaandriana
You also need to create the destination repository first with svnadmin create path/to/newrepos.Could
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?Hanselka
What about the svnserve pack option, isn't it newer and better?Sweeting
@Hadden 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...Kropotkin
This is not the simplest way. The simplest way is to simply copy the repository directory as is or using the svnadmin hotcopy tool.Cement
C
36

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
Common answered 2/6, 2009 at 15:14 Comment(0)
A
24

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:

Atone answered 2/6, 2009 at 14:49 Comment(0)
S
9

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 the svnsync process is the only process permitted to modify the mirror repository.

Smokestack answered 29/6, 2010 at 16:57 Comment(0)
L
6

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 and svnadmin 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.

Longsighted answered 10/7, 2016 at 4:11 Comment(0)
P
4

You can create a dump file using svnadmin dump, then import to a new repository with svnadmin load.

Polygenesis answered 2/6, 2009 at 14:47 Comment(0)
A
3

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.

Anomalism answered 1/2, 2017 at 10:29 Comment(0)
F
0

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.

Fash answered 23/6, 2014 at 12:14 Comment(0)
E
0

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

https://github.com/tonyduckles/svn2svn

Elimination answered 4/1, 2018 at 17:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.