gitlab迁移

备份

备份时需要保持gitlab处于正常运行状态,直接执行 gitlab-rake gitlab:backup:create 进行备份

使用以上命令会在 /var/opt/gitlab/backups 目录下创建一个名称类似为1584426664_gitlab_backup.tar或者1530156812_2018_06_28_10.8.4_gitlab_backup.tar的压缩包

留意关键配置

/etc/gitlab/gitlab.rb 配置文件须备份
/var/opt/gitlab/nginx/conf nginx配置文件
/etc/postfix/main.cf postfix 邮件配置备份
gitlab_rails[‘backup_path’] = “/var/opt/gitlab/backups”

gitlab恢复

  • 拷贝

    scp root@44.88.11.22:/var/opt/gitlab/backups/1584426664_gitlab_backup.tar .

  • 停止相关数据连接服务

    [root@gitlab ~]# gitlab-ctl stop unicorn
    [root@gitlab ~]# gitlab-ctl stop sidekiq

  • 恢复

    ls /var/opt/gitlab/backups
    [root@gitlab ~]# gitlab-rake gitlab:backup:restore BACKUP=1584426664
    从1530156812_2018_06_28_10.8.4编号备份中恢复
    按照提示输入两次yes并回车
    修改权限

启动gitlab

[root@gitlab ~]# gitlab-ctl start

修改域名配置

vim /etc/gitlab/gitlab.rb
external_url ‘http://gitlab.exx.cn/'

vim nginx/gitlab.conf

gitlab-ctl reconfigure && gitlab-ctl start

测试

浏览器访问新服务器的地址进行查看,迁移成功