简体   繁体   English

如何将SVN存储库迁移到另一个SVN存储库?

[英]How do I migrate an SVN repository to another SVN repository?

有没有一种简单的方法可以将目录从一个存储库复制到另一个存储库并复制所有历史记录?

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 . 这将在文件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: 第5章存储库维护 - >迁移存储库数据在其他地方有关于使用版本1.7的svnadmin dump注意事项:

The Subversion repository dump format describes versioned repository changes only. Subversion存储库转储格式仅描述版本化存储库更改。 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. 它不会携带有关未提交的事务,文件系统路径上的用户锁,存储库或服务器配置自定义(包括钩子脚本)等的任何信息。

As suggested in the Subversion book : 正如Subversion书中所建议的那样:

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

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. 如果您不想要历史记录,可以使用svn export获取没有.svn文件夹的干净文件夹,然后将svn import到您的其他存储库中。

With history, you would need to use the svnadmin dump . 有了历史记录,您需要使用svnadmin dump You would then use svndumpfilter to filter for only the parts or paths you want to use before using svnadmin load . 然后,在使用svnadmin load之前,您将使用svndumpfilter仅过滤要使用的部分或路径。

Topics to read: 主题阅读:

Use the svnsync — Subversion Repository Mirroring command: 使用svnsync - Subversion存储库镜像命令:

svnsync is the Subversion remote repository mirroring tool. svnsync是Subversion远程存储库镜像工具。 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命令的Subversion文档具有以下警告(从版本1.7开始),这意味着一旦使用其他一些SVN命令修改镜像存储库, svnsync不应再次与该特定镜像一起使用:

svnsync is very sensitive to changes made in the mirror repository that weren't made as part of a mirroring operation. svnsync对镜像存储库中所做的更改非常敏感,这些更改不是作为镜像操作的一部分进行的。 To prevent this from happening, it's best if the svnsync process is the only process permitted to modify the mirror repository. 为了防止这种情况发生,最好是svnsync进程是唯一允许修改镜像存储库的进程。

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. 在Subversion版本1.7中,有一个新命令svnrdump ,它可用于访问远程存储库并生成与svnadmin dump命令生成的转储格式相同的转储格式。 This allows you to use svnrdump with svnadmin load to transfer a Subversion repository. 这允许您使用带有svnadmin load svnrdump来传输Subversion存储库。

See svnrdump—Remote Subversion Repository Data Migration which has an explanation of the new command. 请参阅svnrdump-Remote Subversion存储库数据迁移 ,其中包含新命令的说明。

In Chapter 5 of the red book, the section Migrating Repository Data Elsewhere has a sub-section Repository data migration using svnrdump that mentions: 在红皮书的第5章中, 迁移存储库数据Elsewhere部分有一个子部分使用svnrdump存储库数据迁移 ,该部分提到:

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. [ svnrdumpsvnadmin dump ]之间的主要区别在于, svnrdump不需要直接访问存储库, svnrdump使用与Subversion客户端完全相同的存储库访问(RA)协议进行远程操作。 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. 此外,您的远程交互[原文如此]受Subversion服务器上配置的任何授权限制。

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 . 我还假设svnadmin dump有关服务器配置自定义(如挂钩)的限制可能无法转移也适用于svnrdump

您可以使用svnadmin dump创建转储文件,然后使用svnadmin load导入到新的存储库。

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 可以使用该命令创建(从svn 1.7开始)

   svnrdump dump url_to_repos > dumpfile

This is useful when done from a remote computer and not the server. 当从远程计算机而不是服务器完成时,这很有用。

In case this helps others, there is svn2svn to replay changesets from one Subversion repository to another: 如果这有助于其他人,则有svn2svn可以将变更集从一个Subversion存储库重放到另一个:

https://github.com/tonyduckles/svn2svn https://github.com/tonyduckles/svn2svn

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. 步骤1:将所有存储库版本转储到转储文件中。 You might be having thousands of versions in the existing repository. 您可能在现有存储库中拥有数千个版本。 So you can create a dump file using the following script. 因此,您可以使用以下脚本创建转储文件。

dump.sh 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 (ie from 0-5000, then from 5001-10000 and so on). 在上面的脚本中,您可能会根据空间可用性获得旧存储库的完整转储,或者您可以在短时间间隔(即0-5000,然后从5001-10000等)获取转储。

Step 2: Execute the above script using the below command. 步骤2:使用以下命令执行上述脚本。 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. 这将使用上述命令将您必须执行的所有命令写入stdout.sh文件。 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. 步骤3:检查旧服务器和新服务器之间的端口号22的防火墙是否打开。 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. 步骤4:现在使用以下命令将从旧SVN存储库生成的所有转储文件复制到新服务器。

$ 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. 在上面的命令中, xxxx是正在执行操作的用户。 In the process of doing sftp you are copying the dump files from the old server to the new server. 在执行sftp的过程中,您将转储文件从旧服务器复制到新服务器。

Step 5: Create a new repository to the new Server 步骤5:为新服务器创建新存储库

$ svnadmin create <new_repository>

Step 6: Now use the below script to load all the dump files. 步骤6:现在使用以下脚本加载所有转储文件。

load.sh 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. 通过此过程,您无需担心现有存储库的损坏修订。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM