在Linux环境下进行GitLab的数据迁移与升级是一个复杂的过程,需要仔细规划和执行。以下是一个基本的指南,涵盖了数据迁移和升级策略的详细步骤。
备份原GitLab服务器
sudo gitlab-ctl stop unicorn
sudo gitlab-ctl stop sidekiq
gitlab-rake
命令创建备份:sudo gitlab-rake gitlab:backup:create
备份文件通常位于 /var/opt/gitlab/backups/
目录下。安装新服务器上的GitLab
cat /opt/gitlab/embedded/service/gitlab-rails/VERSION
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.rpm.sh | sudo bash
sudo EXTERNAL_URL "https://gitlab.example.com"
yum install -y gitlab-ee
传输备份文件到新服务器
scp
或其他文件传输工具将备份文件传输到新服务器:scp /var/opt/gitlab/backups/1513578325_2017_12_18_gitlab_backup.tar username@src_ip:/var/opt/gitlab/backups/
其中 username
是新服务器的用户名,src_ip
是新服务器的IP地址。恢复数据到新服务器
sudo gitlab-rake gitlab:backup:restore BACKUP=1513578325_2017_12_18_gitlab_backup.tar
注意:BACKUP 的时间点必须与原服务器备份后的文件名一致。更新新服务器上的GitLab配置
/etc/gitlab/gitlab.rb
文件,更新数据库连接信息和其他相关配置。重新配置并启动GitLab
sudo gitlab-ctl reconfigure
sudo gitlab-ctl start
验证迁移结果
查看当前版本
cat /opt/gitlab/embedded/service/gitlab-rails/VERSION
备份
sudo gitlab-ctl stop unicorn
sudo gitlab-ctl stop sidekiq
gitlab-rake
命令创建备份:sudo gitlab-rake gitlab:backup:create
下载并安装新版本
sudo gitlab-ctl stop unicorn
sudo gitlab-ctl stop sidekiq
wget https://packages.gitlab.com/gitlab/gitlab-ce/packages/el/8/gitlab-ce-15.0.0-ce.0.el8.x86_64.rpm
sudo rpm -ivh gitlab-ce-15.0.0-ce.0.el8.x86_64.rpm
重新配置并启动GitLab
sudo gitlab-ctl reconfigure
sudo gitlab-ctl start
验证升级结果