LoginSignup
6
6

More than 5 years have passed since last update.

S3上のファイル(サブディレクトリ込み)をGCSに移行するための手順

Posted at

gsutilでS3上のファイル(サブディレクトリ込み)をGCSに移行するための手順です。既にGCPのプロジェクトが作成されていることは前提となります。

(1)Google Cloud SDKのインストール
windowsはやったことありませんが、Linux/Macならとても簡単にインストール可能です。
https://developers.google.com/cloud/sdk/#Quick_Start

(2)認証
OAuth2による認証をおこないます。
$ gcloud auth login

(3)プロジェクトのセット
$ gcloud config set project プロジェクト名

(4)設定ファイル(.boto)の生成
$ gsutil config

(5)設定ファイルの編集
$ vim .boto
以下の2行のコメントアウトを削除しAWSのアクセスキーとシークレットアクセスを設定します。
aws_access_key_id = <your aws access key ID>
aws_secret_access_key = <your aws secret access key>

(6)移動元のS3ファイルの確認
移動元のファイルは以下の通りです。
・Bucket名:tomorier
・サブディレクトリ名:sub-dir
スクリーンショット 2014-07-16 16.09.47.png

(7)移動先のGCSバケットの作成
$ gsutil mb gs://tomorier-gcs

(8)S3のファイルをGCSに移動
以下のコマンドからサブディレクト毎ファイルをGCSに移動します。
$ gsutil mv s3://tomorier/sub-dir gs://tomorier-gcs
Copying s3://tomorier/sub-dir/ [Content-Type=binary/octet-stream]...
Removing s3://tomorier/sub-dir/...
Copying s3://tomorier/sub-dir/サンプル1.png [Content-Type=image/png]...
Removing s3://tomorier/sub-dir/サンプル1.png....png: 65.18 KB/72.68 KB
Copying s3://tomorier/sub-dir/サンプル2.png [Content-Type=image/png]...
Removing s3://tomorier/sub-dir/サンプル2.png....png: 65.18 KB/72.68 KB
Copying s3://tomorier/sub-dir/サンプル3.png [Content-Type=image/png]...
Removing s3://tomorier/sub-dir/サンプル3.png....png: 65.18 KB/72.68 KB

(9)S3の確認
移動元のファイルが消えていることが確認できます。
スクリーンショット 2014-07-16 16.16.08.png

(10)GCSの確認
無事移動できました。
スクリーンショット 2014-07-16 16.17.19.png

もちろん、GCSからS3への移動も可能です。

6
6
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
6
6