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
(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の確認
移動元のファイルが消えていることが確認できます。
もちろん、GCSからS3への移動も可能です。