Because my old Gitlab is running on a Ubuntu 16.04 server. The latest LTS version of Ubuntu is already 18.04 for more than one year. I was thinking about to directly upgrade the server from 16.04 to 18.04. There are still some chances it may fail and the server may crash. I can not afford to lose the data.
So the final decision is to migrate the Gitlab from the old server Ubuntu 16.04 to a new server with Ubuntu 18.04.
This is how to do it.
First, I install the new server on my Proxmox VE environment with Ubuntu 18.04. 3CPU Cores and 4GB memory and 64GB storage. Meanwhile, the old server still uses Ubuntu 16.04. And the Gitlab version that I use is 12.4.2
On the Old Server
- Shutdown Gitlab service
sudogitlab-ctl stop unicornsudogitlab-ctl stop sidekiq - Backup Gitlab on the old server
sudogitlab-rake gitlab:bakcup:create - Create a folder named gitlab-old
mkdir~/gitlab-old - Copy the backup file to the folder ~/gitlab-old
sudocp~/backups/xxxxxxxx_gitlab_backup.tar~/gitlab-old - Copy the Gitlab configuration files
sudocp/etc/gitlab/gitlab.rb ~/gitlab-oldsudocp/etc/gitlab/gitlab-secrets.json ~/gitlab-oldsudocp-R/etc/gitlab/ssl~/gitlab-old
Then all the important files are under folder ~/gitlab-old
My configuration of Gitlab changed the backup folder to ~/backups. The default path is /var/opt/gitlab/backups/
You can change it on the “Backup Settings” section in the file gitlab.rb

To verify the version of your gitlab installation, enter the following command.
sudo gitlab-rake gitlab:env:info
On the New Server
The server is a clean installation of Ubuntu 18.04. The only service is SSH and postfix.
Before doing the migration, I transfer the whole folder ~/gitlab-old from the old server to this new server.
- Add Gitlab source
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh |sudobash - Install Gitlab 12.4.2 CE
sudoapt updatesudoaptinstallgitlab-ce=12.4.2 - Copy the configuration files to folder /etc/gitlab
sudocp~/gitlab-old/gitlab*/etc/gitlab - Copy the ssl folder to folder /etc/gitlab
sudocp-R ~/gitlab-old/ssl/etc/gitlab - Run Gitlab service for the first time
sudogitlab-ctl reconfigure - Shutdown the Gitlab services
sudogitlab-ctl stop unicornsudogitlab-ctl stop sidekiq - Copy the backup file to ~/backups then change the permission
sudocp~/gitlab-old/*.tar~/backupssudochowngit:root ~/backups/*.tar - Restore the Gitlab backup file
sudogitlab-rake gitlab:backup:restore BACKUP=XXXXXX - Restart Gitlab and check
sudogitlab-ctl startsudogitlab-rake gitlab:check SANITIZE=true
There are some notes for the above nine steps.
The backup file name looks like 1573175514_2019_11_07_12.4.2_gitlab_backup.tar. So the code in the step 8, BACKUP=1573175514_2019_11_07_12.4.2
The version of Gitlab I am using 12.4.2. I install the 12.4.2 on step 2. When I do the restore in step 8, it displays the error, the version does not match. The backup is 12.4.2, but the installation is 12.4.1. I have to do the apt update and apt upgrade to upgrade the Gitlab from 12.4.1 to 12.4.2. I am not sure where the problem came from. Just a reminder, double-check the version installed on the new server.
At the first step of adding the repo source, I always get the network error on my server. I believed it is the problem of guest OS on Proxmox VE. So I actually add the repo source and public key of gitlab source manually.
My current Gitlab information on the new server Ubuntu 18.04
davidyin@gitlab:~$ sudo gitlab-rake gitlab:env:infoSystem informationSystem: Ubuntu 18.04Current User: gitUsing RVM: noRuby Version: 2.6.3p62Gem Version: 2.7.9Bundler Version:1.17.3Rake Version: 12.3.3Redis Version: 3.2.12Git Version: 2.22.0Sidekiq Version:5.2.7Go Version: unknownGitLab informationVersion: 12.4.2Revision: 393a5bdafa2Directory: /opt/gitlab/embedded/service/gitlab-railsDB Adapter: PostgreSQLDB Version: 10.9URL: https://gitlab.g2soft.netHTTP Clone URL: https://gitlab.g2soft.net/some-group/some-project.gitSSH Clone URL: git@gitlab.g2soft.net:some-group/some-project.gitUsing LDAP: noUsing Omniauth: yesOmniauth Providers:GitLab ShellVersion: 10.2.0Repository storage paths:- default: /var/opt/gitlab/git-data/repositoriesGitLab Shell path: /opt/gitlab/embedded/service/gitlab-shellGit: /opt/gitlab/embedded/bin/git |
At the end, I should give the credit to Didiet A. Pambudiono. Most of the steps above is based on this post.




