在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
驗證升級結果