How do I migrate an SVN repository to another SVN

2019-01-16 05:19发布

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

9条回答
迷人小祖宗
2楼-- · 2019-01-16 06:06

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
查看更多
来,给爷笑一个
3楼-- · 2019-01-16 06:06

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.

查看更多
地球回转人心会变
4楼-- · 2019-01-16 06:13

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.

查看更多
登录 后发表回答