利用メモ。 コンソール右記より ∥ AWS Management Console Command Line Interface (CLI)本家では S3 用の CLI ツールは用意していないようです。「Command-line Access to S3 : Sample Code & Libraries : Amazon Web Services」ということなので、「Amazon S3 tools: s3cmd : command line S3 client」の “s3cmd” を使ってみます。 こんなものもあるようですが、OS X では動かなさそうだしな…。でもこれならば、モノホンの rsync が効くかな? リンクが使えないからダメかな? ∥ s3fs - FUSE-based file system backed by Amazon S3 - Google Project Hosting うわ、何だこれ ∥ Home - OSXFUSE AWS のリンク先にあるバージョンは古すぎる上に Perl で書かれている(うっかり間違ったぜ。ソースや CPAN で頑張っても入りやしない)のですが、現行版は Python で書かれています。Mac OS X だと Homebrew に入っているので、そのまま使わせてもらいます。GnuPG が入っていると、コンテンツ暗号化送受信もできるので、ついでに入れておきます。 $ brew install gpg $ brew install s3cmd $ s3cmd --configure Enter new values or accept defaults in brackets with Enter. Refer to user manual for detailed description of all options. Access key and Secret key are your identifiers for Amazon S3 Access Key: XXXXXXXXXXXXXXXXXXXX Secret Key: XxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXx Encryption password is used to protect your files from reading by unauthorized persons while in transfer to S3 Encryption password: ******** Path to GPG program [/usr/local/bin/gpg]: When using secure HTTPS protocol all communication with Amazon S3 servers is protected from 3rd party eavesdropping. This method is slower than plain HTTP and can't be used if you're behind a proxy Use HTTPS protocol [No]: yes New settings: Access Key: XXXXXXXXXXXXXXXXXXXX Secret Key: XxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXx Encryption password: ******** Path to GPG program: /usr/local/bin/gpg Use HTTPS protocol: True HTTP Proxy server name: HTTP Proxy server port: 0 Test access with supplied credentials? [Y/n] y Please wait... Success. Your access key and secret key worked fine :-) Now verifying that encryption works... Success. Encryption and decryption worked fine :-) Save settings? [y/N] y Configuration saved to '/Users/knaka/.s3cfg' $ ls -l ~/.s3cfg -rw------- 1 knaka staff 1175 5 9 XX:XX /Users/knaka/.s3cfg $単純なコマンドだけでなく、ローカルディレクトリとの同期ができると聞いたので、使ってみます。 $ echo hello > hoge.txt $ s3cmd put hoge.txt s3://ayutaya.com/ hoge.txt -> s3://ayutaya.com/hoge.txt [1 of 1] 6 of 6 100% in 0s 8.97 B/s done $ s3cmd ls s3://ayutaya.com/ 2012-XX-XX XX:XX 6 s3://ayutaya.com/hoge.txt $ mkdir foo $ echo bar > foo/bar.txt $ echo buzz > foo/buzz.txt $ s3cmd sync foo s3://ayutaya.com/ foo/bar.txt -> s3://ayutaya.com/foo/bar.txt [1 of 2] 4 of 4 100% in 0s 22.24 B/s done foo/buzz.txt -> s3://ayutaya.com/foo/buzz.txt [2 of 2] 5 of 5 100% in 0s 56.37 B/s done Done. Uploaded 9 bytes in 0.3 seconds, 31.49 B/s $ echo bar >> foo/bar.txt $ s3cmd sync foo s3://ayutaya.com/ foo/bar.txt -> s3://ayutaya.com/foo/bar.txt [1 of 1] 7 of 7 100% in 0s 78.06 B/s done Done. Uploaded 7 bytes in 0.1 seconds, 70.08 B/s おお、すごいなこれは。ディレクトリごと S3 へ同期 → EMR で Hive フローを起動 → 終わったらローカルへ同期、の指示がローカルのコマンドラインだけでできる。 そして最新版では multipart upload にも(sync モードでも)対応しているようです。完璧ではありませんか。 APIその他Links内部外部 |
AWS >