gitlab 10.8.1 迁移

参考官网: https://docs.gitlab.com/ee/raketasks/backup_restore.html    Backing up and restoring GitLab

及 https://www.cnblogs.com/wenwei-blog/p/6362829.html    gitlab服务器迁移

https://www.ilanni.com/?p=13917   烂泥:gitlab版本升级

1.查看新旧gitlab服务器版本

查看gitlab版本的命令:

gitlab-rake gitlab:env:info

新的gitlab服务器(记为b)与旧的gitlab(记为a)类型和版本要一致,否则可能迁移不成功。

You can only restore a backup to exactly the same version and type (CE/EE) of GitLab on which it was created.

另外,你可以登录旧gitlab的Admin area查看

2.安装小工具

sudo yum install rsync

校验tar版本大于1.30

tar --version

3.先关闭a服务器gitlab部分服务

防止你备份数据的时候还有人更新

gitlab-ctl stop unicorn

gitlab-ctl stop sidekiq

gitlab-ctl stop nginx

4. 备份原a服务器上的的数据

gitlab-rake gitlab:backup:create 
PS: 备份后的文件一般是位于/var/opt/gitlab/backups下, 自动生成文件名文件名
如1527519647_2018_05_28_10.8.1_gitlab_backup.tar
以前的备份文件不带日期,如1527496365_gitlab_backup.tar
不知道从什么时候开始带上日期了。


默认备份以下所有模块:
db (database)
uploads (attachments)
repositories (Git repositories data)
builds (CI job output logs)
artifacts (CI job artifacts)
lfs (LFS objects)
registry (Container Registry images)
pages (Pages content)
如果在后续第6步恢复的时候有部分模块失败,可以跳过某几块
比如:sudo gitlab-rake gitlab:backup:create SKIP=uploads

注:
Use this command if you’ve installed GitLab with the Omnibus package:
sudo gitlab-rake gitlab:backup:create

Use this if you’ve installed GitLab from source:
sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production

5.备份配置文件
/etc/gitlab/gitlab.rb
/var/opt/gitlab/gitlab-rails/etc/unicorn.rb

6. 将步骤2生成的tar文件拷贝到b服务器上相应的backups目录下
可以利用scp进行直接拷贝.
在b服务器上执行
scp username@src_ip:/var/opt/gitlab/backups/1542385134_2018_11_17_10.8.1_gitlab_backup.tar /var/opt/gitlab/backups
PS: username为原服务器的用户名,src_ip原服务器IP地址

7. 在b服务器恢复数据

保证备份文件放在新服务器的/var/opt/gitlab/backups下,如果没有,移过去

mv 1542385134_2018_11_17_10.8.1_gitlab_backup.tar /var/opt/gitlab/backups/
gitlab-rake gitlab:backup:restore  BACKUP=1527496365
PS:BACKUP的时间点必须与原服务器备份后的文件名一致

8.修改配置文件

/etc/gitlab/gitlab.rb

/var/opt/gitlab/gitlab-rails/etc/unicorn.rb

9.重启gitlab

gitlab-ctl reconfigure

gitlab-ctl stop

gitlab-ctl start

10,登录验证

登录新gitlab的Admin area查看

projects、users、groups是否数目一样。

原文地址:https://www.cnblogs.com/newalan/p/9970767.html