Using Ubuntu 18.04 via a Vagrant Virtualbox VM I migrated a back up from my VPS to a VM at home.

This document was made using the guide available at: https://docs.gitlab.com/ee/raketasks/backup_restore.html#restore-for-omnibus-gitlab-installations

In old VM:
Backup Gitlab Environment (12.1 and earlier):

sudo gitlab-rake gitlab:backup:create

Backup Gitlab Environment (12.2 and later):

sudo gitlab-backup create

In your new VM:
Create file:

sudo vim /etc/apt/sources.list.d/gitlab_gitlab-ce.list

Enter data:

# this file was generated by packages.gitlab.com for
# the repository at https://packages.gitlab.com/gitlab/gitlab-ce

deb https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu/ bionic main
deb-src https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu/ bionic main

Get the GPGKEY

curl -L https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey | sudo apt-key add -

You will need to go to https://packages.gitlab.com/gitlab/gitlab-ce and search at the top for your version, click on the appropriate distribution, and then look on the right where they have the text to copy to install.

Example: Version 13.3.6 reads as:

sudo apt-get install gitlab-ce=13.3.6-ce.0

Then:

sudo apt-get update
EXTERNAL_URL="http://gitlab.yourdomain.com"
sudo apt-get install gitlab-ce=[your old gitlab version]

Note:
Look in your Gitlab Environment on the Admin page, it is listed on the right. Also it is generally saved in the filename of the backup.

sudo gitlab-ctl reconfigure
sudo gitlab-ctl stop unicorn
sudo gitlab-ctl stop puma
sudo gitlab-ctl stop sidekiq
sudo gitlab-ctl status

Copy your backup file to the backup directory

sudo mv backup.tar /var/opt/gitlab/backups/

Set the ‘git:root’ user as owner

sudo chown git:root /var/opt/gitlab/backups/*

Restore your Gitlab environment (12.1 and earlier):

sudo gitlab-rake gitlab:backup:restore BACKUP=

Restore your Gitlab environment (12.2 and later):

sudo gitlab-backup restore BACKUP=
sudo gitlab-ctl reconfigure

Copy your secrets back

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

Reconfigure, restart, and check

sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart
sudo gitlab-rake gitlab:check SANITIZE=true

That’s all, thanks!

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.