如何将所有回购从gitlab迁移到bitbucket

我的公司正在评估bitbucket作为我们的中央VCS。 我们目前使用gitlab 7.13.4。 我们已经寻找了一种自动化的方式将我们所有的gitlab回购迁移到bitbucket,但我的search已经空了。 每次做这个事情都有很多例子,但是没有任何事情可以做到这一点。 通过数百个回购,我们希望使用一个具有良好可靠性的stream程。

作为奖励有一种方法来自动迁移组和权限?

你可以使用Bit Bucket REST api,下面是我用来将一个版本库导入到bitbucket的一些Perl:

#!/usr/bin/perl use strict; use warnings; use Data::Dumper; use File::Basename; my $numArgs = $#ARGV + 1; if($numArgs < 2) { die "Usage: $0 [Bit Bucket Project eg FW, BDPE] [repo name] [-d dry run (optional)]"; } my $bitbucketProject = lc $ARGV[0]; my $repoName = $ARGV[1]; my $dryRun = $ARGV[2]; my %moduleHash; my $bitBucketServer = "localhost"; my $user = "admin"; my $password = "bitbucket"; print "Bit Bucket Project: $bitbucketProject\n"; print "Repository name: $repoName\n"; sub importRepo { my $command = sprintf("curl -u %s:%s -X POST -H \"Content-Type: application/json\" -d '{ \"name\": \"%s\", \"scmId\": \"git\", \"forkable\": true \}' http://%s:7990/rest/api/1.0/projects/%s/repos", $user, $password, $repoName, $bitBucketServer, $bitbucketProject); if ($dryRun) { print "$command\n"; } else { print "Doing import\n"; system $command; } my $bitbucketUrl = sprintf("ssh://git\@%s:7999/%s/%s.git", $bitBucketServer, lc $bitbucketProject, $repoName); my $gitCommand = sprintf("cd %s; pwd; git repack -a -d -f; git push %s --mirror", $repoName, $bitbucketUrl); if ($dryRun) { print "$gitCommand\n"; } else { print "Running git\n"; system $gitCommand; } } importRepo(); 

然后你可以用shell脚本来包装它:

 #!/bin/bash BITBUCKETPROJECT=$1 if [ $# -ne 2 ]; then echo "Usage: $0 [Bit Bucket Project] [Path to repos]" exit 1; fi echo "Bit bucket project: $BITBUCKETPROJECT" for f in *; do if [[ -d $f ]]; then echo $f ./importRepository.pl $BITBUCKETPROJECT $f fi done 

假设您的所有回购已被克隆到当前目录。

https://developer.atlassian.com/static/rest/bitbucket-server/latest/bitbucket-rest.html