Migrate GitLab Server

Migrate GitLab Server


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 latest proxmox virtualization.

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 :

  1. Shutdown GitLab services
sudo gitlab-ctl stop unicorn
sudo gitlab-ctl stop sidekiq
sudo gitlab-ctl stop puma
  1. Run the GitLab backup
sudo gitlab-rake gitlab:backup:create
  1. create folder migration and backup all the necessary data :
  1. scp those backup data to new server

On NEW server :

  1. install gitlab-ce
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
apt-get install gitlab-ce
  1. copy all the old data from folder migration back to etc/gitlab
gitlab.rb gitlab-secrets.json ssl/* config_backup/*
  1. 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

  1. shutdown the service
sudo gitlab-ctl stop unicorn
sudo gitlab-ctl stop sidekiq
sudo gitlab-ctl stop puma
  1. copy the backup repo
sudo cp gitlab-old/XXXXXXXXXX_gitlab_backup.tar /var/opt/gitlab/backups
  1. change the owner to git
sudo chown git.git /var/opt/gitlab/backups/XXXXXXXXXX_gitlab_backup.tar
  1. 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.

  1. start the service again
sudo gitlab-ctl start
  1. check all
sudo gitlab-rake gitlab:check SANITIZE=true
  1. done

Wrapping up

That’s it. The new gitlab server is running perfectly now. oh no ! anyway, back to code. see you.

Tags :
comments powered by Disqus

Related Posts

zsh shell

zsh shell

If you work on many projects and always jump from one to another, there are times when you forget which branch you are standing on.

Read More
Northern Lights

Northern Lights

Weird, beautiful, eerie, and kind of mystical.

Read More