LoginSignup
10
11

More than 3 years have passed since last update.

Google Compute Engine 上に構築した Redmine の添付ファイルフォルダを Google Cloud Storage バケットにマップする

Last updated at Posted at 2016-08-13

Cloud Storage FUSE を使って redmine/filesフォルダに Google Cloud Storage のバケットをマップします。

Compute Engine のスコープ確認

Compute Engine にstorage-full のスコープが設定されている必要があります。インスタンス作成時に コマンドラインなら

gcloud compte instances create --scopes default="https://www.googleapis.com/auth/devstorage.full_control"

の指定を、Web UIなら「ID と API へのアクセス」でストレージ>フルの設定を忘れないようにしてください。
作成済みのインスタンスへのスコープ追加は

gcloud beta compute instances set-scopes INSTANCE_NAME --zone=ZONE --scopes=storage-full 

でできます。後からスコープ追加のコマンドは2016年12月ころに追加されました。

GCS バケットの用意

https://console.cloud.google.com/storage/browser で適当なバケットを作ってください。
本稿ではバケット名を [your-bucket-name-for-redmine-upload] と表現します。

GCSFUSE のインストール

Ubuntu 16.04 での例。他のディストリビューションは gcsfuseインストール を参照してください。

リポジトリ追加

export GCSFUSE_REPO=gcsfuse-`lsb_release -c -s`
echo "deb http://packages.cloud.google.com/apt $GCSFUSE_REPO main" | sudo tee /etc/apt/sources.list.d/gcsfuse.list
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -

パッケージ更新・インストール

sudo apt-get update
sudo apt-get install gcsfuse

既存ファイルのバックアップ

redmine/files フォルダの中身をバックアップします。
以下は Redmine のインストールフォルダが /var/lib/redmine でのケース。

cp -R /var/lib/redmile/files /tmp

マウント

redmine のユーザーアカウントとしてマウントししてください。後からchownできません。

sudo -u www-data gcsfuse --file-mode "777" --dir-mode "755" [your-bucket-name-for-redmine-upload] /var/lib/redmine/files

バックアップの復帰

sudo -u www-data cp -R /tmp/files /var/lib/redmine
10
11
3

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
10
11