Wissensdatenbank
Buehl, Kevin
04 April 2018
04 April 2018
1.731

Wissensdatenbank

GitLab Community Edition auf einen neuen Server migrieren

Vorwort


Ich habe meine Infrastruktur von LXC auf Docker migriert, auch die Migration von GitLab ist keine grosse Sache, sofern man ein paar DInge beachtet. Aus diesem Grund erkläre ich hier, wie Sie Ihr GitLab auf einen neuen Server migrieren.

Altes System


Aktualisieren


Auf beiden Systemen muss zwingend die gleiche Version installiert sein, da Sie sonst beim einspielen des Backups folgende Meldung erhalten:
GitLab version mismatch:
Your current GitLab version (10.6.2) differs from the GitLab version in the backup!
Please switch to the following version and try again:
version: 10.6.0

apt update
apt -y upgrade
     _______ __  __          __
/ ____(_) /_/ / ____ _/ /_
/ / __/ / __/ / / __ `/ __ \
/ /_/ / / /_/ /___/ /_/ / /_/ /
\____/_/\__/_____/\__,_/_.___/


Upgrade complete! If your GitLab server is misbehaving try running
sudo gitlab-ctl restart

Sicherung erstellen


/opt/gitlab/bin/gitlab-rake gitlab:backup:create
Dumping database ...
Dumping PostgreSQL database gitlabhq_production ... [DONE]
done
Dumping repositories ...
* 4b42/cms ... [DONE]
[...]
done
Dumping uploads ...
[...]
Dumping lfs objects ...
done
Dumping container registry images ...
[DISABLED]
Creating backup archive: 1522863106_2018_04_04_10.6.0_gitlab_backup.tar ... done
Uploading backup archive to remote storage ... skipped
Deleting tmp directories ... done
done
done
Deleting old backups ... skipping
Kopieren Sie das Backup anschliessend auf den neuen Server:
scp /var/opt/gitlab/backups/1522863106_2018_04_04_10.6.0_gitlab_backup.tar 10.48.42.1:/gitlab/data/backups/



Neues System


docker exec -it vdrc01 /bin/bash

Dienste beenden


gitlab-ctl stop unicorn
ok: down: unicorn: 1s, normally up
gitlab-ctl stop sidekiq
ok: down: sidekiq: 1s, normally up

Prüfen Sie ob die Dienste beendet wurden:
gitlab-ctl status
run: gitaly: (pid 456) 502s; run: log: (pid 438) 502s
run: gitlab-monitor: (pid 421) 502s; run: log: (pid 418) 502s
run: gitlab-workhorse: (pid 428) 502s; run: log: (pid 426) 502s
run: logrotate: (pid 423) 502s; run: log: (pid 420) 502s
run: nginx: (pid 452) 502s; run: log: (pid 430) 502s
run: node-exporter: (pid 424) 502s; run: log: (pid 419) 502s
run: postgres-exporter: (pid 457) 502s; run: log: (pid 442) 502s
run: postgresql: (pid 429) 502s; run: log: (pid 427) 502s
run: prometheus: (pid 443) 502s; run: log: (pid 440) 502s
run: redis: (pid 417) 502s; run: log: (pid 416) 502s
run: redis-exporter: (pid 454) 502s; run: log: (pid 436) 502s
down: sidekiq: 6s, normally up; run: log: (pid 437) 502s
run: sshd: (pid 28) 513s; run: log: (pid 27) 513s
down: unicorn: 19s, normally up; run: log: (pid 422) 502s


Sicherung wiederherstellen


Berechtigungen setzen:
chown git:git /var/opt/gitlab/backups/*.tar
gitlab-rake gitlab:backup:restore BACKUP=1522864062_2018_04_04_10.6.2
WARNING:  no privileges were granted for "public"
GRANT
[DONE]
done
Restoring repositories ...
* 4b42/cms ... [DONE]
[...]
Put GitLab hooks in repositories dirs [DONE]
done
Restoring uploads ...
done
[...]
This will rebuild an authorized_keys file.
You will lose any data stored in authorized_keys file.
Do you want to continue (yes/no)? yes

.........
Deleting tmp directories ... done
[...]
done


Dienste starten


gitlab-ctl reconfigure
gitlab-ctl start
gitlab-rake gitlab:check SANITIZE=true