在Debian環境下遷移GitLab項目涉及多個步驟,包括備份現有項目、安裝新的GitLab實例以及恢復項目數據。以下是一個詳細的遷移策略:
備份現有GitLab項目:
sudo gitlab-rake gitlab:backup:create CRON1
或手動備份單個項目:PROJECT_ID=$(curl --header "PRIVATE-TOKEN: your_access_token" "http://your_gitlab_instance/api/v4/projects" | jq -r '.[] | select(.name == "project_name") | .id')
sudo gitlab-rake gitlab:backup:create PROJECT_ID PROJECT_ID CRON1
關閉源實例:
sudo gitlab-ctl stop unicorn
sudo gitlab-ctl stop sidekiq
sudo gitlab-ctl stop nginx
評估遷移策略:
在新服務器上安裝GitLab:
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
sudo EXTERNAL_URL="http://new_gitlab_instance" apt-get install gitlab-ce
將 new_gitlab_instance
替換為你的新GitLab實例的URL。配置新的GitLab實例:
/etc/gitlab/gitlab.rb
文件,確保 external_url
設置正確。sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart
恢復整個備份:
sudo gitlab-rake gitlab:backup:restore BACKUP_YYYY-MM-DD-HH-mm-ss
將 YYYY-MM-DD-HH-mm-ss
替換為你備份文件的日期和時間。
恢復單個項目:
BACKUP_FILE
。sudo gitlab-rake gitlab:backup:restore BACKUP BACKUP_FILE PROJECT_ID project_id
將 backup_file_name
替換為你的備份文件名,project_id
替換為你的項目ID。