Migrate GitLab Server
- jfdesignnet
- Linux , Application
- December 10, 2020
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 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 :
- 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.
- 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. The new gitlab server is running perfectly now. oh no ! anyway, back to code. see you.