How to migrate a GitLab CE installation


Transfer a GitLab CE installation from one local server to another one.


For the migration to work, the old and new GitLab CE servers need the identical GitLab version installed.


On the old server, a full backup can be created like this:

sudo gitlab-backup create

The backup wil be saved to the default location /var/opt/gitlab/backups/, if not other specified in /etc/gitlab/gitlab.rb.

Transfer backup to new server

scp /var/opt/gitlab/backups/1617711536_2021_04_06_13.10.2_gitlab_backup.tar sij@NEW-SERVER-IP:/tmp/

Furthermore, the files /etc/gitlab/gitlab.rb and /etc/gitlab/gitlab-secrets.json need to be transferred as well.

scp /etc/gitlab/gitlab.rb sij@NEW-SERVER-IP:/tmp/
scp /etc/gitlab/gitlab-secrets.json sij@NEW-SERVER-IP:/tmp/


These steps are executed on the new server.


First of all move the transferred backup in the right folder and change the owner to git.

sudo cp /tmp/1617711536_2021_04_06_13.10.2_gitlab_backup.tar /var/opt/gitlab/backups/
sudo chown git:git /var/opt/gitlab/backups/ -R

Then, backup the files /etc/gitlab/gitlab.rb and /etc/gitlab/gitlab-secrets.json.

sudo mv /etc/gitlab/gitlab.rb /etc/gitlab/gitlab.rb-bkp
sudo mv /etc/gitlab/gitlab-secrets.json /etc/gitlab/gitlab-secrets.json-bkp

And restore this files.

sudo mv /tmp/gitlab.rb /etc/gitlab/
sudo mv /tmp/gitlab-secrets.json /etc/gitlab/

Before we can import the backup, we need to stop the gitlab services, which interact with the database.

sudo gitlab-ctl stop puma
sudo gitlab-ctl stop sidekiq

We can verify that this two services are stopped.

sudo gitlab-ctl status


The service postgresql needs to be running.

Start the restore

Important - The whole GitLab content will be overwritten.

sudo gitlab-backup restore BACKUP=1617708602_2021_04_06_13.9.3

And after the restore, we need to reconfigure and restart gitlab.

sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart


Link, which helped me.