LoginSignup
4
7

More than 5 years have passed since last update.

Amazon Drive をコマンドラインから操作する rclone の設定と利用方法

Last updated at Posted at 2017-08-01

Amazon Drive の概要

様々なサービスが展開されているクラウドストレージサービスの中でも,「容量無制限」プランを持つ唯一の大手系サービスが Amazon Drive です.一定の金額(日本=13,800円/年,アメリカ=59.99USD/年,イギリス=40.00GBP/年)を支払えば,クラウドストレージを容量無制限で利用できます.

ただ,この「容量無制限」サービス,米国ではまもなく終了するとの報道があります.他の国でもいずれ同様の料金体系が導入されることと思われます.それでもなお,大規模クラウドストレージの中での価格競争力は十分にあります.

「人類最後の希望」Amazon Drive無制限プランが米国で終了。日本版はどうなる?
日本におけるプラン変更は未定
http://japanese.engadget.com/2017/06/13/amazon-drive/

Amazon will stop offering an unlimited Amazon Storage tier from 8 June for US-based customers, currently not confirmed a UK price
http://www.cloudpro.co.uk/it-infrastructure/cloud-storage/4932/amazon-drive-will-no-longer-offer-unlimited-storage-tier

Amazon Driveは,他の主要クラウドストレージとは異なり,ローカルPCとの同期だけではなく,ファイルをクラウド上にどんどん送り込む方式も採用しています.そのため,ローカルPCのディスク容量が危機に陥ったときの緊急避難としての利用も可能です.

唯一とも言える欠点として,Amazonが用意している独自アプリもしくはウェブブラウザを介したアップロードとダウンロードしかできない点があります.Linuxをベースとするユーザにとっては,非常に大きな問題です.

コマンドラインから Amazon Drive を操作する rclone

この欠点を解決する方法として,コマンドラインから Amazon Drive を操作する外部ツールを利用する,という手があります.

代表的なツールとして,acd_clirclone が挙げられますが,公式ページのドキュメントの充実度を考慮して,ここでは rclone を採用します.

rclone のインストール

大まかなインストール手順は 公式ページ に書かれています.これに従えば,特に問題はないでしょう.以下は,MacOSを想定して一通りの手順です.

$ mkdir -p rclone
$ curl -O https://downloads.rclone.org/rclone-current-osx-amd64.zip
$ unzip -a rclone-current-osx-amd64.zip
$ cd rclone-*-osx-amd64
  (* にはバージョンが入る.2017年7月末現在ではv1.37のはず.)
# sudo mv rclone /usr/local/bin/
# cd ..
# rm -rf rclone-*-osx-amd64 rclone-current-osx-amd64.zip

rclone の初期設定

初期設定の手順も 公式ページ https://rclone.org/amazonclouddrive/ に書いてあるように見えるのですが,実はこれでは動きません(参照:https://forum.rclone.org/t/rclone-has-been-banned-from-amazon-drive/2314 ).

代替策として,rclone forumで提案されている方法が,共用のpublic proxyを利用する方法です.その具体的な手順は, https://forum.rclone.org/t/proxy-for-amazon-cloud-drive/2848 に記載されています.「proxyではデータの中身も認証情報も覗いていません」と宣言していますが,もし不安な場合には,ご自身で developer credential を確保する必要があると思います.

以下にも,その手順を記載しておきます.

# rclone config

No remotes found - make a new one
n) New remote
s) Set configuration password
q) Quit config
n/s/q> n
name> acd
Type of storage to configure.
Choose a number from below, or type in your own value
 1 / Amazon Drive
   \ "amazon cloud drive"
 2 / Amazon S3 (also Dreamhost, Ceph, Minio)
   \ "s3"
 3 / Backblaze B2
   \ "b2"
 4 / Dropbox
   \ "dropbox"
 5 / Encrypt/Decrypt a remote
   \ "crypt"
 6 / FTP Connection
   \ "ftp"
 7 / Google Cloud Storage (this is not Google Drive)
   \ "google cloud storage"
 8 / Google Drive
   \ "drive"
 9 / Hubic
   \ "hubic"
10 / Local Disk
   \ "local"
11 / Microsoft OneDrive
   \ "onedrive"
12 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
   \ "swift"
13 / SSH/SFTP Connection
   \ "sftp"
14 / Yandex Disk
   \ "yandex"
Storage> 1
Amazon Application Client Id - required.
client_id> rclone
Amazon Application Client Secret - required.
client_secret> acd
Auth server URL - leave blank to use Amazon's.
auth_url> https://quixotic-module-170120.appspot.com/auth
Token server url - leave blank to use Amazon's.
token_url> https://quixotic-module-170120.appspot.com/token
Remote config
Make sure your Redirect URL is set to "http://127.0.0.1:53682/" in your custom config.
Use auto config?
 * Say Y if not sure
 * Say N if you are working on a remote or headless machine
y) Yes
n) No
y/n> y
If your browser doesn't open automatically go to the following link: http://127.0.0.1:53682/auth
Log in and authorize rclone for access
Waiting for code...
Got code
--------------------
[acd]
client_id = rclone
client_secret = acd
auth_url = https://quixotic-module-170120.appspot.com/auth
token_url = https://quixotic-module-170120.appspot.com/token
token = XXXX
--------------------
y) Yes this is OK
e) Edit this remote
d) Delete this remote
y/e/d> y

rclone の利用

上記の rclone config が正常に終了すれば,あとは利用するのみです.

リモート(=クラウド側にあるストレージ)のディレクトリ・ファイルを一覧する.LINUX系では ls に相当します.

# rclone lsd acd:

acd: は,rclone configで設定したsecretと同じ文字列を指定し,リモートの仮想マシン名を示します.

リモートのディレクトリ・ファイルの詳細情報を確認.LINUX系のls -lに相当.

# rclone lsl acd:

ディレクトリを作成.

# rclone mkdir /Users/akisato/rclone-test
  (ローカル側でのディレクトリ作成)
# rclone mkdir acd:rclone-test
   (リモート側でのディレクトリ作成)

ローカルからリモートへのファイルのコピー.LINUX系のようにコピー元にワイルドカードを使うことはできない模様.

# rclone copy /Users/akisato/rclone-test/test.txt acd:rclone-test/

ローカルとリモートの順序を変えれば,リモートからローカルへファイルをコピーできる.

# rclone copy acd:rclone-test/test.txt /Users/akisato/rclone-test/

ワイルドカード相当のコピーをしたい場合には,例えばfindとxargsを組み合わせる.

# find /Users/akisato/rclone-test -name "*.txt" | xargs -n1 -L1 -I{} rclone copy {} acd:rclone-test/

ローカルとリモートを同期する.

# rclone sync /Users/akisato/rclone-test acd:

残りの詳細は, 公式ドキュメント を参照して下さい.

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