由于一些因素,需要把gitlab从A服务器搬迁到B服务器,现记录步骤如下:
1. 查看A服务器的gitlab版本号:
cat /opt/gitlab/embedded/service/gitlab-rails/VERSION
2. 在B服务器安装相同版本的gitlab:
sudo apt-get update
sudo apt-get install -y curl openssh-server ca-certificates
sudo apt-get install -y postfix
去gitlab官网找到指定版本的gitlab,依次执行红色框的两个命令:https://packages.gitlab.com/gitlab/gitlab-ce
打开/etc/gitlab/gitlab.rb,将external_url = 'http://git.example.com'修改为自己的域名地址:http://example.com,默认为80端口,如要使用其他端口后面加上端口号,如:http://127.0.0.1:8080
更新配置:sudo gitlab-ctl reconfigure
重启服务:sudo gitlab-ctl restart
3. 在A服务器上创建备份
# 进入root模式
sudo su
cd /opt/gitlab/etc/gitlab-rails
gitlab-rake gitlab:backup:create RAILS_ENV=production
# 备份文件放置在 /var/opt/gitlab/backups 下,进入到该目录下拷贝到B服务器的 /var/opt/gitlab/backups 目录下。
# 在B服务器上执行以下命令
sudo su
cd /var/opt/gitlab/backups
chmod 777 1617158735_2021_03_31_13.0.0_gitlab_backup.tar
cd /opt/gitlab/bin
gitlab-rake gitlab:backup:restore RAILS_ENV=production BACKUP=1617158735_2021_03_31_13.0.0
大功告成!
后续:gitlab迁移后发现有些project无法转移到其它组,也无法删除,解决办法参见:
https://blog.csdn.net/u014173215/article/details/108413390
https://www.jianshu.com/p/768809e8e542
进入gitlab控制台:
sudo gitlab-rails dbconsole
SELECT * FROM public."ci_group_variables";
SELECT * FROM public."ci_variables";
UPDATE projects SET runners_token = null, runners_token_encrypted = null;
UPDATE namespaces SET runners_token = null, runners_token_encrypted = null;
UPDATE application_settings SET runners_registration_token_encrypted = null;
UPDATE ci_runners SET token = null, token_encrypted = null;
exit
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)