DEV Community

dom
dom

Posted on • Edited on

How to Migrate a Self-Hosted GitLab Instance (Docker-Based) to a New Machine

Using the usual rclone sync casaos:/DATA/AppData/gitlab-ee/ /DATA/AppData/gitlab-ee/ -P --create-empty-src-dirs -l doesn't help because lot's of copy errors, and symlinks don't endup being remade thus gitlab fails to start up on new server.

Nice optional have:

gitlab-rails console
# wait for startup (its slow)
::Gitlab::CurrentSettings.update!(maintenance_mode: true)
Enter fullscreen mode Exit fullscreen mode

Start from here:

gitlab-backup create  
/DATA/AppData/gitlab-ee/data/backups
# echo 1735565802_2024_12_30_17.5.1-ee_gitlab_backup.tar
Enter fullscreen mode Exit fullscreen mode

Create the docker on new server

Restore on new one

# OPTIONAL: Create the /opt/gitlab/data/backups directory, including any parent directories if they don't exist
mkdir -p /DATA/AppData/gitlab-ee/data/backups

Enter fullscreen mode Exit fullscreen mode

get inside container or use docker exec -t <name of container>

gitlab-ctl stop puma&&gitlab-ctl stop sidekiq&&gitlab-ctl status

Execute the command inside the running "gitlab-backend" container to stop the Puma service

gitlab-ctl stop puma
Execute the command inside the running "gitlab-backend" container to stop the Sidekiq service

gitlab-ctl stop sidekiq
Verify that the GitLab services have stopped by checking the status of all services in the container

gitlab-ctl status

Run the GitLab backup restore command inside the running "gitlab-backend" container (restore to specific)
gitlab-backup restore BACKUP=1735565802_2024_12_30_17.5.1-ee_gitlab_backup
Autodetect / better - especially if you provide the file correctly yet it still pretends to "fail" to find it:
gitlab-backup restore force=yes


NOT INCLUDED IN BACKUP:
"/DATA/AppData/gitlab-ee/config/gitlab.rb"
"/DATA/AppData/gitlab-ee/config/gitlab-secrets.json"
will need to transfer them manually

Run the GitLab reconfigure command inside the running "gitlab-backend" container
docker exec -t gitlab-backend gitlab-ctl reconfigure

Restart the "gitlab-backend" container after reconfiguration
docker restart gitlab-backend
Done!

Top comments (0)