Ubuntu环境下GitLab迁移指南
GitLab迁移是确保代码托管服务连续性的关键操作,需严格遵循步骤以避免数据丢失。以下是基于Ubuntu系统的详细迁移流程及注意事项:
curl、openssh-server)。sudo gitlab-rake gitlab:backup:create
备份文件默认存储在/var/opt/gitlab/backups目录,文件名格式为YYYY-MM-DD-HH-mm-ss_gitlab_backup.tar。sudo gitlab-ctl stop unicorn
sudo gitlab-ctl stop sidekiq
sudo gitlab-ctl stop nginx
curl https://packages.gitlab.com/gpg.key | sudo apt-key add -
echo "deb https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/gitlab.list
sudo apt-get update
your-new-gitlab-url):sudo apt-get install gitlab-ce
sudo EXTERNAL_URL="http://your-new-gitlab-url" gitlab-ctl reconfigure
scp将原服务器备份文件复制到新服务器的/var/opt/gitlab/backups目录(需确保目标目录存在且具备git用户写入权限):scp -r user@old-server:/var/opt/gitlab/backups/* user@new-server:/var/opt/gitlab/backups/
git),然后执行恢复命令(将YYYY-MM-DD-HH-mm-ss替换为实际备份文件名):sudo chown git:git /var/opt/gitlab/backups/your_backup_file.tar
sudo gitlab-rake gitlab:backup:restore BACKUP=your_backup_file
/etc/gitlab/gitlab.rb,根据新服务器环境修改以下关键参数:
external_url:设置为新服务器的访问URL(如http://new-ip或域名);gitlab_rails['gitlab_shell_ssh_port']:若SSH端口变更,需同步更新;sudo gitlab-ctl reconfigure
sudo gitlab-ctl start
sudo gitlab-ctl enable
EXTERNAL_URL,确认GitLab首页能正常加载。git clone新地址,推送提交),确认仓库功能正常;