要将存储库从一台服务器迁移到另一个版本,您需要遵循以下步骤。
第 1 步:将所有存储库版本转储到转储文件中。您可能在现有存储库中有数千个版本。因此,您可以使用以下脚本创建转储文件。
转储.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
在上面的脚本中,您可能会根据可用空间获得旧存储库的完整转储,或者您可以在短时间内进行转储(即从 0-5000,然后从 5001-10000 等等)。
第 2 步:使用以下命令执行上述脚本。根据内核版本,您需要执行以下两个查询之一。
$ bash dump.sh > stdout.sh
$ ./sh dump.sh > stdout.sh
这会将您必须使用上述命令执行的所有命令写入 stdout.sh 文件。您可以跟踪此文件以供将来参考。
第 3 步:检查防火墙是否为新旧服务器之间的端口号 22 开放。如果它没有打开,请让您的管理员提供它。
第 4 步:现在使用以下命令将所有从旧 SVN 存储库生成的转储文件复制到新服务器。
$ sftp xxxx@<new_server>
Connecting to <new_server>…
Password:
sftp> mput *.dump <new_server>/dump_location
在上述命令中,xxxx 是正在执行操作的用户。在执行 sftp 的过程中,您将转储文件从旧服务器复制到新服务器。
第 5 步:为新服务器创建一个新存储库
$ svnadmin create <new_repository>
第 6 步:现在使用以下脚本加载所有转储文件。
加载.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
只需按照上述六个简单步骤,您就可以将现有存储库迁移到新存储库。通过这个过程,您无需担心现有存储库的损坏修订。