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

You may want to check your git repo for issues (for more information see https://docs.gitlab.com/ee/administration/raketasks/check.html):

sudo gitlab-rake gitlab:git:fsck
sudo gitlab-rake gitlab:artifacts:check
sudo gitlab-rake gitlab:lfs:check
sudo gitlab-rake gitlab:uploads:check

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:

Get the GPGKEY

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

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

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
export 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 -R /var/opt/gitlab/backups

Restore your Gitlab environment (12.1 and earlier):
Note, it will append ‘_gitlab_backup.tar’ to the end of the file name you put after the ‘=’ sign

sudo gitlab-rake gitlab:backup:restore BACKUP=

Restore your Gitlab environment (12.2 and later):
Note, it will append ‘_gitlab_backup.tar’ to the end of the file name you put after the ‘=’ sign

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

Add  a backup cron tab entry (04:03 AM on Sunday)

3 4 * * 0 gitlab-backup create SKIP=registry > /root/gitlabbackup.log

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.