INNOBASE技術ブログ

技術的なことエンジニア的なこと制作的なこと全般

GitLabのお引っ越し(サーバー移行)

プロローグ

redmineとconfluenceとgitlabを同じサーバーで動かしていたら…
メモリたんなくなったらしくmerge requestできんくなったねん(´・ω・`)
ということでgitlabのお引越しです。

公式ドキュメントを読む

今更だがrequirements 確認

GitLab.org / GitLab Community Edition | GitLab

  • 推奨環境
    • CPU 2 core
    • mem 2G

ごめん、3core 2GのさくらVPSにいろいろ詰め込んでて本当にごめん

気を取り直して、公式のドキュメントを見ると簡単そう

GitLab.org / GitLab Community Edition | GitLab
backup

# omnibus-gitlab
sudo gitlab-rake gitlab:backup:create

# installation from source or cookbook
bundle exec rake gitlab:backup:create RAILS_ENV=production

restore

# omnibus-gitlab
sudo gitlab-rake gitlab:backup:restore

# installation from source or cookbook
bundle exec rake gitlab:backup:restore RAILS_ENV=production

バックアップ

早速バックアップ
$ gitlab-rake gitlab:backup:create
Dumping database ... 
Dumping PostgreSQL database gitlabhq_production ... [DONE]
done
Dumping repositories ...
 * innobase/repository_test ... [DONE]
 * innobase/repository_test.wiki ... [SKIPPED]
 * innobase/repository_dummy ... [DONE]
(中略)
done
Dumping uploads ... 
done
Creating backup archive: 1410765027_gitlab_backup.tar ... done
Deleting tmp directories ... done
Deleting old backups ... skipping
ファイルを確認
$ find / -name 1410765027_gitlab_backup.tar
/var/opt/gitlab/backups/1410765027_gitlab_backup.tar

新環境構築

念のため、最新版とかじゃなくて旧環境と同じバージョンをもってきてinstall
$ sudo rpm -ivh  gitlab-7.1.1_omnibus-1.el6.x86_64.rpm
準備中...                ########################################### [100%]
   1:gitlab                 ########################################### [100%]
Thank you for installing GitLab!
You can configure GitLab for your system by running the following command:

sudo gitlab-ctl reconfigure
とりあえず初期化
$ sudo gitlab-ctl reconfigure
(中略 chefが走る)
Chef Client finished, 129/142 resources updated in 78.639845184 seconds
gitlab Reconfigured!
バックアップファイルを設置
# scp とかで適当に設置
$ sudo ls -la  /var/opt/gitlab/backups/
合計 51588
drwx------  2 git  root     4096  915 17:17 2014 .
drwxr-xr-x 10 root root     4096  915 17:05 2014 ..
-rw-r--r--  1 git  git  52817920  915 17:16 2014 1410765027_gitlab_backup.tar
restore
$ sudo gitlab-rake gitlab:backup:restore
(中略 postgre とかrepositoryとかやってくれる)
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 # git user の authorized_keys 上書きの確認

.........Deleting tmp directories ... done

動いたー!!!
あら簡単(^^)
これでもまだ merge request が失敗して調整に苦しむのはまた別のお話