How to migrate Gitlab repository manager

GitLab is an open source end-to-end software development platform with built-in version control, issue tracking, code review, CI/CD, and more.

This article explains detailed steps to migrate Gitlab repository manager from one Centos server to another.

Step1: Login to the source server through ssh as root.

Step2: Check the installed version of Gitlab and note it.

#gitlab-rake gitlab:env:info

Step3: Shut down Gitlab services.

#gitlab-ctl stop unicorn
#gitlab-ctl stop sidekiq

Step4: Create Gitlab backup.

#gitlab-rake gitlab:backup:create

Step5: Create a folder named gitlab-old.

#mkdir ~/gitlab-old

Step6: Copy the GitLab configurations on folder /etc/gitlab (gitlab.rb and gitlab-secrets.json) and folder /etc/gitlab/ssl to newly created folder.

#cp /etc/gitlab/gitlab.rb ~/gitlab-old/
#cp /etc/gitlab/gitlab-secrets.json ~/gitlab-old/
#cp -R /etc/gitlab/ssl ~/gitlab-old/

Step7: Copy backup file to newly created folder.

#cp /var/opt/gitlab/backups/XXXXXXXXXX_gitlab_backup.tar ~/gitlab-old/

Step8: Copy this folder to destination server's root directory.

Step9: Login to destination server through ssh as root.

Step10: Add Gitlab package source.

#curl -s https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash

Step11: Install the exact same version of Gitllb running on source server.

#yum install gitlab-ce-<version>

Step12: Copy the configuration files from backup folder to folder /etc/gitlab.

#cp ~/gitlab-old/gitlab* /etc/gitlab/

Step13: Copy the ssl folder from backup folder to folder /etc/gitlab.

#cp -R ~/gitlab-old/ssl /etc/gitlab/

Step14: Start Gitlab.

#gitlab-ctl start

Step15: Run GitLab service for the first time.

#gitlab-ctl reconfigure

Step16: Shut down Gitlab services.

#gitlab-ctl stop unicorn
#gitlab-ctl stop sidekiq

Step17: Copy backup file to /var/opt/gitlab/backups.

#cp ~/gitlab-old/XXXXXXXXXX_gitlab_backup.tar /var/opt/gitlab/backups/

Step18: Correct the ownership of backup file.

#chown git:git /var/opt/gitlab/backups/XXXXXXXXXX_gitlab_backup.tar

Step19: Restore the backup.

#gitlab-rake gitlab:backup:restore BACKUP=XXXXXXXXX

Step20: Restart Gitlab.

#gitlab-ctl restart

That's all…

Leave a Reply

Your email address will not be published. Required fields are marked *