How to Migrate GitLab from Old server to New Server?

Tudip

28 February 2019

When migrating Gitlab to a new server, you might face many problems like incompatible versions, different OS (so different latest Gitlab version), etc. Before migrating the Gitlab to the new server, we have to make sure that Gitlab in both servers have the same edition and version (e.g If an old server has Gitlab Community edition with version 11.9 then the new server must have the Gitlab Community edition with the 11.9 version) The best way of doing this is to upgrade the old server to the same latest Gitlab version, then back up the Gitlab, followed by the transfer of the backup to the new server. Install the same latest Gitlab version in the new server, and restore it. We have the Gitlab on Linode server and now we move it to the AWS EC2 instance. We follow the below steps for migration.

Steps for Gitlab Migration to AWS server:

1. Check the version of Gitlab on Linode server.

gitlab-rake gitlab:env:info

2. Update the Gitlab to the latest version with the following commands.

apt-get update
apt-get install gitlab-ce
gitlab-ctl reconfigure
gitlab-ctl restart

3. First, we’ll need to back up the gitlab at the Linode server.

gitlab-rake gitlab:backup:create

4. Then, we have to transfer it to the AWS server (EC2 instance) via SCP.

scp /var/opt/gitlab/backups/XXXXXXXXX_gitlab_backup.tar root@NEW_SERVER_IP:/root/

5. At the AWS server, install the latest version of Gitlab as per the steps mentioned in the blog ‘Gitlab Installation On Ubuntu’.

6. After the installation of Gitlab on AWS server, run the Gitlab reconfigure for the first time.

gitlab-ctl reconfigure

7. After the Gitlab is started successfully, stop unicorn and sidekiq processes.

gitlab-ctl stop unicorn
gitlab-ctl stop sidekiq

8. Move the backup to the backup folder.

mv /root/XXXXXXXXX_gitlab_backup.tar /var/opt/gitlab/backups/

9. Run the restore command.

gitlab-rake gitlab:backup:restore BACKUP=XXXXXXXXX

10. Restart Gitlab and check.

gitlab-ctl start
gitlab-rake gitlab:check SANITIZE=true

11. Access Gitlab UI.

Now you can access gitlab through the IP address of the EC2 Instance.

 

Request a quote