CentOS下GitLab迁移步骤
sudo yum update -y)。sudo yum install -y curl policycoreutils-python openssh-server openssh-clients postfix
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --permanent --add-service=ssh
sudo firewall-cmd --reload
/var/opt/gitlab/backups):sudo gitlab-rake gitlab:backup:create
备份文件命名格式为YYYY-MM-DD-HH-MM-SS_gitlab_backup.tar(如2025-09-26-14-30-00_gitlab_backup.tar)。/etc/gitlab/gitlab.rb),其中包含外部URL、SMTP邮件设置等关键参数:sudo cp /etc/gitlab/gitlab.rb /backup/gitlab_config.rb
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
sudo yum install -y gitlab-ce
/etc/gitlab/gitlab.rb,设置外部访问URL(替换为新服务器IP或域名):sudo vi /etc/gitlab/gitlab.rb
# 修改以下行(取消注释并替换)
external_url 'http://新服务器IP'
保存后重新配置GitLab,使设置生效:sudo gitlab-ctl reconfigure
scp将旧服务器的备份文件(含数据目录和配置文件)复制到新服务器的对应目录:scp /var/opt/gitlab/backups/2025-09-26-14-30-00_gitlab_backup.tar root@新服务器IP:/var/opt/gitlab/backups/
scp /backup/gitlab_config.rb root@新服务器IP:/etc/gitlab/gitlab.rb
sudo gitlab-ctl stop unicorn
sudo gitlab-ctl stop sidekiq
sudo gitlab-rake gitlab:backup:restore BACKUP=2025-09-26-14-30-00 # 替换为备份文件的时间戳部分
gitlab.rb覆盖新服务器的配置文件,确保设置一致:sudo cp /etc/gitlab/gitlab.rb /etc/gitlab/gitlab.rb.bak # 备份新服务器原有配置
sudo cp /backup/gitlab_config.rb /etc/gitlab/gitlab.rb
sudo gitlab-ctl reconfigure # 重新应用配置
sudo gitlab-ctl start
sudo systemctl enable gitlab
http://新服务器IP),使用旧服务器的管理员账号登录,检查以下内容:
root或git用户操作,避免权限不足;