Migrating Your GitLab Server Backup to a New Server: A Step by Step Guide

  • Access to the current GitLab server (old server).
  • A newly set up server with the same or compatible operating system.
  • Sufficient disk space to accommodate the backup.
  • Proper user permissions and SSH access.

Check the GitLab Version

sudo gitlab-rake gitlab:env:info
$ sudo gitlab-rake gitlab:backup:create
Gitlab Take Backup

By default, the backup is stored in  /var/opt/gitlab/backups/1685286600_2023_05_28_15.9.3-ee_gitlab_backup.tar. dentify the latest backup file:

Gitlab Backup File
ls -lh /var/opt/gitlab/backups/
sudo cp /etc/gitlab/gitlab.rb /var/opt/gitlab/backups/
sudo cp /etc/gitlab/gitlab-secrets.json /var/opt/gitlab/backups/

Transfer Backup file to new Gitlab server.

Gitlab Backup file transfer

Stop services

Now, stop the processes which are related to the database by using the below commands.

sudo gitlab-ctl stop unicorn
sudo gitlab-ctl stop sidekiq

Verify Status

sudo gitlab-ctl status
git_data_dirs       ({
"default" => {"path" => "/var/opt/gitlab/git-data"},
"alternative" => { "path" => "/var/opt/gitlab/gitstorage" }
})

Restore backup

sudo gitlab-rake gitlab:backup:restore BACKUP = 1685286600_2023_05_28_15.9.3-ee_gitlab_backup.tar

Copy Gitlab Configuration Files

sudo cp /etc/gitlab/gitlab.rb /etc/gitlab/
sudo cp /etc/gitlab/gitlab-secrets.json /etc/gitlab/

Reconfigure GitLab:

sudo gitlab-ctl reconfigure

Restart Gitlab services

Restart the GitLab components by using the below command

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

6- Post-Migration Tasks

Check Logs for Errors

Run the following command to check for any issues:

sudo gitlab-ctl tail

Reindex GitLab Data

sudo gitlab-rake gitlab:elastic:reindex

Update DNS and Firewall Rules

sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable

Read related Topics

How to Downgrade Gitlab Server from 16.0.1.ee to 15.9.3.ee: A step by step Guide.

Conclusion

FAQs

1. Can I migrate GitLab to a server with a different OS?

2. What happens if my backup is corrupted?

3. How can I reduce downtime during migration?

4. Do I need to update GitLab after migration?

Previous Post
Next Post

Leave a Reply

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