gitlab サーバ移行

・移行元と移行先のgitlabのバージョンを揃える

doc/raketasks/backup_restore.md · master · GitLab.org / GitLab Community Edition · GitLab


SSH host keys

Migrate GitLab Instance to new Host – pikedom.com

mattermost

gitlab-ce 付属のmattermost。mattermost のデータベース、データは gitlab のバックアップに含まれないので別途移行が必要

移行元

バックアップ作成

sudo -u mattermost -i bash
/opt/gitlab/embedded/bin/pg_dump -U gitlab_mattermost -h /var/opt/gitlab/postgre
sql -p 5432 mattermost_production > /tmp/mattermost_production_backup.sql
exit

cd /var/opt/gitlab/
tar cvzf /tmp/mattermost.tar.gz mattermost

移行先にバックアップファイルをコピー

移行先

(データベース mattermost_production とデータベースユーザ gitlab_mattermost が存在しない場合)

gitlab-ctl reconfigure

リストア

gitlab-ctl stop mattermost

sudo -u gitlab-psql -i bash
/opt/gitlab/embedded/bin/dropdb -U gitlab-psql -h /var/opt/gitlab/postgresql/ mattermost_production
/opt/gitlab/embedded/bin/createdb -U gitlab-psql -h /var/opt/gitlab/postgresql/ mattermost_production
/opt/gitlab/embedded/bin/psql -U gitlab-psql -h /var/opt/gitlab/postgresql/ postgres -c "ALTER DATABASE mattermost_production OWNER TO gitlab_mattermost"
exit

sudo -u mattermost -i bash
cat /tmp/mattermost_production_backup.sql | /opt/gitlab/embedded/bin/psql -U gitlab_mattermost -h /var/opt/gitlab/postgresql/ mattermost_production
exit

cd /tmp
tar xvzf mattermost.tar.gz

cd /var/opt/gitlab/mattermost 
mv config.json config.json.bak 
mv data data.bak

mv /tmp/mattermost/config.json config.json 
mv /tmp/mattermost/data data 

gitlab-ctl start mattermost

Migration Guide — Mattermost 5.12 documentation

Is Mattermost Backup included in GitLab Backup? - GitLab Mattermost - Matttermost, Inc.