LoginSignup
4
3

More than 5 years have passed since last update.

マニュアルインストールのGitlabをOmnibus(CE)に移行する

Last updated at Posted at 2017-07-13

この記事は

  • 昔々、Omnibus GitlabなんてものがなかったころマニュアルインストールしたGitlabのOmnibusへの移行メモです
  • バージョン1つずつ上げながらrake db:migrateしたり、手作業でworkhorseコンパイルしたりする地獄運用をやめたい。

前提

  • Ubuntu14
  • 現行のGitlabバージョン:8.11.3(古)

Omnibus Gitlabのインストール

  • 別のマシンに普通にOmmnibus Gitlabをインストールする
  • まずは準備
$ apt-get install curl openssh-server ca-certificates postfix
$ curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh > /tmp/script.deb.sh
$ chmod 777 /tmp/script.deb.sh
  • 移行元と完全に同じバージョンを入れる必要があるのでバージョンを確認してバージョン指定でインストールします
$ apt-cache policy gitlab-ce

(snip)
     8.11.3-ce.1 0
        500 https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu/ trusty/main amd64 Packages
(snip)

$ apt-get install gitlab-ce=8.11.3-ce.1
$ gitlab-ctl reconfigure
  • 普通にアクセスできるかブラウザから確認します

マニュアルgitlabのバックアップ実行

  • マニュアルgitlab側で下記コマンドでバックアップを作成します
$ cd /home/git/gitlab
$ /usr/local/rvm/gems/ruby-2.1.8/bin/bundle exec rake gitlab:backup:create RAILS_ENV=production
  • ちなみにバックアップの設定は下記のような感じです(元々S3に飛ばしてたのでその設定が入っていますが必須ではありません)
/home/git/gitlab/config/gitlab.yml
  backup:
    path: "tmp/backups"   # Relative paths are relative to Rails.root (default: tmp/backups/)
    keep_time: 1   # default: 0 (forever) (in seconds)
    upload:
      connection:
        provider: AWS
        region: ap-northeast-1
        aws_access_key_id: XXXXX
        aws_secret_access_key: 'XXXXX'
      remote_directory: 'xxx-gitlab-backups'

Omnibus Gitlabへバックアップを取り込み

secret情報の復旧

  • 上記で取得したバックアップファイルはDB関連の情報が暗号化されているようで、復号化キーを元の環境から持ってくる必要があります
  • キーのありかはバージョンによって微妙に異なるみたいです

マニュアルインストール側

/home/git/gitlab/config/secrets.yml
production:
  db_key_base: xxxxxxx
  secret_key_base: xxxxxxx
  otp_key_base: xxxxxxx

omnibus側

/etc/gitlab/gitlab-secrets.json
  "gitlab_rails": {
    "secret_key_base": "xxxxxxx",
    "db_key_base": "xxxxxxx",
    "otp_key_base": "xxxxxxx"
  },
  • マニュアル側のファイルからomnibus側のファイルへ3つのキーをコピペで張りつけておきます

バックアップ取り込みの実行

  • バックアップファイルを所定のディレクトリに配置します
    • tarが1つだけの場合は何も指定しなくてもそれを取り込むみたいです
mv /tmp/1499828797_gitlab_backup.tar /var/opt/gitlab/backups
  • 取り込みを実施します
/opt/gitlab/bin/gitlab-rake gitlab:backup:restore RAILS_ENV=production

無事

  • 取り込みに成功して普通にアクセスできるようになりました

ついでに

  • せっかくomnibusにしたので、最新のGitlabにupdateしました
apt-get install gitlab-ce
  • 最新の9.3.6に簡単に上がりました

終わりに

  • omnibusだとアップデート楽だなぁ(マニュアルは地獄)
4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3