Migrating GitLab from one server to another

May 26, 2020 in Software by Volkor2 minutes

Using an external postgres database

Caution

This is a Legacy blog post. I wrote this many years ago. The content may not be up to date or relevant in the current times. Please google elsewhere if you’re following this as a single source.

So I have a gitlab server, it’s running on https://git.volkor.me/ I use it for my personal projects, along with learning how to properly setup environments and such.

Pre-Migration

  1. Ensure the old server is up to date. sudo apt update && sudo apt dist-upgrade
  2. Create a backup sudo gitlab-rake gitlab:backup:create
  3. copy this backup to the new server scp /var/opt/gitlab/backups/XXXXXXXXX_gitlab_backup.tar NEW_SERVER_IP:~

Setup

  1. Actually Install gitlab on the new server now
  2. Create the user and database in postgres, with the same user/pass and such (READ NODE AT THE BOTTOM)
  3. ensure you’ve copied the gitlab.rb and gitlab-secrets.json too!
  4. run gitlab-ctl reconfigure
  5. stop unicorn and sidekiq gitlab-ctl stop unicorn && gitlab-ctl stop sidekiq
  6. move the backup to the correct directory (default: /var/opt/gitlab/backups)
  7. run the restore command: gitlab-rake gitlab:backup:restore BACKUP=XXXXXXXXX
  8. start gitlab again, and check everything. gitlab-ctl start && gitlab-rake gitlab:check SANITIZE=true

Note at the bottom

Due to this bug/error you must temporarily give superuser permissions to postgres user (git) do this for the first reconfigure then.

sudo -u postgres psql

Give superuser: alter role git superuser;

Revoke superuser alter role git nosuperuser;

All done

You’re done now, you can close this page (or look at my other stuff I guess)

like comment and subscribe