Introduction

Due to server management changes and preservation, we had to move the ongoing production GitLab server to another virtual cloud server. Other than that reason, the old server that using proxmox is already really outdated and imposible to upgrade due to hardware spec limitation, so this is a good time to move to another cloud server with the latest proxmox virtualization release.

However, migrating or moving any production server always have an own risk. Especially, if the running production server version is outdated and the system administrator never or cannot update them due to company policy or else. The other problem is the OS version, sometimes the old GitLab version cannot installed to new OS version due to package dependencies librares or else.

So, there are 2 possibility here :

  1. Upgrade the GitLab version on old server so it have the same version with on the new server, then use the backup/restore function to migrate the data. This is a high risk method, especially if the GitLab version is too old and there are problem during upgrading.
  2. Use the same old GitLab version on new server. This is safer for the data but it's not easy if the GitLab version is no longer supported on the new OS version server.

Fortunately on this case, I am their system administrator. I always update the GitLab version on the old server to the latest stable version, so on this case I'm using possibility number 1.

Migration steps

On OLD server :

  • Shutdown GitLab services
 sudo gitlab-ctl stop unicorn
 sudo gitlab-ctl stop sidekiq
 sudo gitlab-ctl stop puma
  • Run the GitLab backup
 sudo gitlab-rake gitlab:backup:create
  • Create folder migration and backup all the necessary data :
 etc/gitlab/gitlab.rb
 etc/gitlab/gitlab-secrets.json
 etc/gitlab/ssl/*
 etc/gitlab/config_backup/*
 var/opt/gitlab/backup/*
  • scp those backup data to new server

On NEW server :

  • Install gitlab-ce
 curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
 apt-get install gitlab-ce
  • Copy all the old data from folder migration back to etc/gitlab
 gitlab.rb gitlab-secrets.json ssl/* config_backup/*
  • Run gitlab configure to initialize installation
 sudo gitlab-ctl reconfigure

it will finish without problem and tell you something about the root password should empty, and you should change on the next login and so on, just ignore it

  • Shutdown the service
 sudo gitlab-ctl stop unicorn
 sudo gitlab-ctl stop sidekiq
 sudo gitlab-ctl stop puma
  • Copy the backup repo
 sudo cp gitlab-old/XXXXXXXXXX_gitlab_backup.tar /var/opt/gitlab/backups
  • Change the owner to git
 sudo chown git.git /var/opt/gitlab/backups/XXXXXXXXXX_gitlab_backup.tar
  • Run the GitLab restore
 sudo gitlab-rake gitlab:backup:restore BACKUP=XXXXXXXXX

(remember to only supply the backupname XXXX only, without _gitlab_backup.tar)
this should be a long wait depends on the repo size.

  • Start the service again
 sudo gitlab-ctl start
  • Check all
 sudo gitlab-rake gitlab:check SANITIZE=true
  • done

Wrapping up

That's it. That is how I migrate the Gitlab server from one instance to another in clouds.
The new gitlab server is running perfectly now. ... oh no ! anyway, back to code. see you.