底なし「BASE Storage」の実力とやらを見せてもらおうではないか!「s3cmd編」(Ubuntu)

底なし「BASE Storage」の実力とやらを見せてもらおうではないか!「s3cmd編」(Ubuntu)

前回は「s3fs」を使ってPC(Ubuntu)に「BASE Storage」をマウントしたわけですが、今回は「s3cmd」でゴニョゴニョしてみようと思います。

個人的には「s3fs」よりも「s3cmd」のほうが使用頻度は高いのではないかと思います。
例えば、cronを使って「s3cmd」でバックアップファイルを定期的に「BASE Storage」に格納したり、巨大なファイルをバックグラウンドで転送したりとか。
僕の場合はさくらのVPSも使っているので、「BASE Storage」へのバックアップは「s3cmd」を使って、
VPSの容量が足りなくなったら「s3fs」の環境作ってマウントして容量増やすもいいし、みたいな感じでいます。
と言っても、、使えるか使えないかは「BASE Storage」の料金次第なんですけどね・・
Amazon S3のほうが低価格であればそっちを使うし。(Amazon S3は料金計算が難しい)
GoogeDriveにしても100Gで$1.99/月になってるので、「BASE Storage」も月数百円くらいで利用できなければいいのですが、それ以上だと個人的には利用できませんといった感じですかね。

範囲を選択_006

s3cmdをインストール

sudo apt-get install s3cmd

 

設定方法はここ見てやる

http://cloud-news.sakura.ad.jp/2014/02/03/base_storage_beta/

 

概要

——————
Access Key: ユーザ名
Secret Key: トークン
を設定するだけで、
Test access with supplied credentials? [Y/n] n にして
「/home/foo/.s3cfg」が作成されるのので、それを手で「BASE Strage」用に修正する。

設定ファイルを作成

s3cmd –configure

——————————————————————-
foo@testname:/etc$ 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: ユーザ名
Secret Key: トークン

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/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]:

On some networks all internet access must go through a HTTP proxy.
Try setting it here if you can’t conect to S3 directly
HTTP Proxy server name:

New settings:
Access Key: ユーザ名
Secret Key: トークン
Encryption password:
Path to GPG program: /usr/bin/gpg
Use HTTPS protocol: False
HTTP Proxy server name:
HTTP Proxy server port: 0

Test access with supplied credentials? [Y/n] n

Save settings? [y/N] y
Configuration saved to ‘/home/foo/.s3cfg’
——————————————————————-

「/home/foo/.s3cfg」の19行目、20行目を修正する

host_base = s3.amazonaws.com
host_bucket = %(bucket)s.s3.amazonaws.com

host_base = b.storage.sakura.ad.jp
host_bucket = %(bucket)s.b.storage.sakura.ad.jp

——————————————————————-

s3cmdの基本コマンド

 

●状態の確認
3cmd info s3://<ネームスペース名>
———————————
s3://testname/ (bucket):
Location: us-east-1

 

●アップロード
s3cmd put <ファイル名> s3://<ネームスペース名>
———————————

 

●ダウンロード

s3cmd get s3://<ネームスペース名>/<オブジェクト名>
——————————–


●一覧表示
s3cmd ls s3://<ネームスペース名>
———————————-
s3cmd ls s3://testname
DIR s3://testname/aa/
2014-03-22 02:18 52311 s3://testname/123.png
2014-03-22 02:18 108933 s3://testname/Pimagizer_005.png
2014-03-22 02:18 42652 s3://testname/aaa.png
2014-03-22 02:18 21 s3://testname/index.html
2014-03-22 02:18 18481 s3://testname/範囲を選択_008.png
2014-03-22 02:18 317806 s3://testname/範囲を選択_009.png
2014-03-22 02:18 34779 s3://testname/範囲を選択_010.png

 

●コピー
s3cmd cp s3://<ネームスペース名>/<オブジェクト名> s3://<ネームスペース名>/<オブジェクト名>
———————————
s3cmd cp s3://testname/aaa.png s3://testname/bbb.png

 

●情報の表示

s3cmd info s3://<ネームスペース名>/<オブジェクト名>
———————————
s3cmd info s3://testname/bbb.png
s3://testname/bbb.png (object):
File size: 42652
Last mod: Sat, 22 Mar 2014 03:48:36 GMT
MIME type: image/png
MD5 sum: ac9d173cdaff15b1ff1a765a3dac0d17

 

●削除

s3cmd del s3://<ネームスペース名>/<オブジェクト名>
———————————
s3cmd del s3://testname/bbb.png
File s3://testname/bbb.png deleted

 

●一覧表示

———————————
s3cmd ls s3://testname
DIR s3://testname/aa/
2014-03-22 02:18 52311 s3://testname/123.png
2014-03-22 02:18 108933 s3://testname/Pimagizer_005.png
2014-03-22 02:18 42652 s3://testname/aaa.png
2014-03-22 02:18 21 s3://testname/index.html
2014-03-22 02:18 18481 s3://testname/範囲を選択_008.png
2014-03-22 02:18 317806 s3://testname/範囲を選択_009.png
2014-03-22 02:18 34779 s3://testname/範囲を選択_010.png

 

 以下は、さくらVPS(Debian)からBASE Storageに957MのファイルをPUTした様子

s3cmd put access_all.log s3://testname
access_all.log -> s3://testname/access_all.log [part 1 of 64, 15MB]
15728640 of 15728640 100% in 2s 6.71 MB/s done
access_all.log -> s3://testname/access_all.log [part 2 of 64, 15MB]
15728640 of 15728640 100% in 3s 4.55 MB/s done
access_all.log -> s3://testname/access_all.log [part 3 of 64, 15MB]
15728640 of 15728640 100% in 2s 6.61 MB/s done
access_all.log -> s3://testname/access_all.log [part 4 of 64, 15MB]
15728640 of 15728640 100% in 4s 3.14 MB/s done
access_all.log -> s3://testname/access_all.log [part 5 of 64, 15MB]
15728640 of 15728640 100% in 1s 7.88 MB/s done
access_all.log -> s3://testname/access_all.log [part 6 of 64, 15MB]
15728640 of 15728640 100% in 1s 8.39 MB/s done
access_all.log -> s3://testname/access_all.log [part 7 of 64, 15MB]
15728640 of 15728640 100% in 1s 8.77 MB/s done
access_all.log -> s3://testname/access_all.log [part 8 of 64, 15MB]
15728640 of 15728640 100% in 1s 7.53 MB/s done
access_all.log -> s3://testname/access_all.log [part 9 of 64, 15MB]
15728640 of 15728640 100% in 1s 10.41 MB/s done
access_all.log -> s3://testname/access_all.log [part 10 of 64, 15MB]
15728640 of 15728640 100% in 2s 5.36 MB/s done
access_all.log -> s3://testname/access_all.log [part 11 of 64, 15MB]
15728640 of 15728640 100% in 2s 6.77 MB/s done
access_all.log -> s3://testname/access_all.log [part 12 of 64, 15MB]
15728640 of 15728640 100% in 3s 4.56 MB/s done
access_all.log -> s3://testname/access_all.log [part 13 of 64, 15MB]
15728640 of 15728640 100% in 1s 9.62 MB/s done
access_all.log -> s3://testname/access_all.log [part 14 of 64, 15MB]
15728640 of 15728640 100% in 2s 6.22 MB/s done
access_all.log -> s3://testname/access_all.log [part 15 of 64, 15MB]
15728640 of 15728640 100% in 2s 5.71 MB/s done
access_all.log -> s3://testname/access_all.log [part 16 of 64, 15MB]
15728640 of 15728640 100% in 1s 7.78 MB/s done
access_all.log -> s3://testname/access_all.log [part 17 of 64, 15MB]
15728640 of 15728640 100% in 1s 9.51 MB/s done
access_all.log -> s3://testname/access_all.log [part 18 of 64, 15MB]
15728640 of 15728640 100% in 1s 9.10 MB/s done
access_all.log -> s3://testname/access_all.log [part 19 of 64, 15MB]
15728640 of 15728640 100% in 1s 7.52 MB/s done
access_all.log -> s3://testname/access_all.log [part 20 of 64, 15MB]
15728640 of 15728640 100% in 1s 9.75 MB/s done
access_all.log -> s3://testname/access_all.log [part 21 of 64, 15MB]
15728640 of 15728640 100% in 1s 10.43 MB/s done
access_all.log -> s3://testname/access_all.log [part 22 of 64, 15MB]
15728640 of 15728640 100% in 1s 11.59 MB/s done
access_all.log -> s3://testname/access_all.log [part 23 of 64, 15MB]
15728640 of 15728640 100% in 1s 9.85 MB/s done
access_all.log -> s3://testname/access_all.log [part 24 of 64, 15MB]
15728640 of 15728640 100% in 1s 8.95 MB/s done
access_all.log -> s3://testname/access_all.log [part 25 of 64, 15MB]
15728640 of 15728640 100% in 3s 4.14 MB/s done
access_all.log -> s3://testname/access_all.log [part 26 of 64, 15MB]
15728640 of 15728640 100% in 3s 4.23 MB/s done
access_all.log -> s3://testname/access_all.log [part 27 of 64, 15MB]
15728640 of 15728640 100% in 2s 5.47 MB/s done
access_all.log -> s3://testname/access_all.log [part 28 of 64, 15MB]
15728640 of 15728640 100% in 3s 3.81 MB/s done
access_all.log -> s3://testname/access_all.log [part 29 of 64, 15MB]
15728640 of 15728640 100% in 2s 6.49 MB/s done
access_all.log -> s3://testname/access_all.log [part 30 of 64, 15MB]
15728640 of 15728640 100% in 2s 6.77 MB/s done
access_all.log -> s3://testname/access_all.log [part 31 of 64, 15MB]
15728640 of 15728640 100% in 3s 4.83 MB/s done
access_all.log -> s3://testname/access_all.log [part 32 of 64, 15MB]
15728640 of 15728640 100% in 2s 5.62 MB/s done
access_all.log -> s3://testname/access_all.log [part 33 of 64, 15MB]
15728640 of 15728640 100% in 1s 8.08 MB/s done
access_all.log -> s3://testname/access_all.log [part 34 of 64, 15MB]
15728640 of 15728640 100% in 1s 9.53 MB/s done
access_all.log -> s3://testname/access_all.log [part 35 of 64, 15MB]
15728640 of 15728640 100% in 2s 6.66 MB/s done
access_all.log -> s3://testname/access_all.log [part 36 of 64, 15MB]
15728640 of 15728640 100% in 3s 4.96 MB/s done
access_all.log -> s3://testname/access_all.log [part 37 of 64, 15MB]
15728640 of 15728640 100% in 2s 5.66 MB/s done
access_all.log -> s3://testname/access_all.log [part 38 of 64, 15MB]
15728640 of 15728640 100% in 1s 8.82 MB/s done
access_all.log -> s3://testname/access_all.log [part 39 of 64, 15MB]
15728640 of 15728640 100% in 1s 11.02 MB/s done
access_all.log -> s3://testname/access_all.log [part 40 of 64, 15MB]
15728640 of 15728640 100% in 1s 7.66 MB/s done
access_all.log -> s3://testname/access_all.log [part 41 of 64, 15MB]
15728640 of 15728640 100% in 1s 8.39 MB/s done
access_all.log -> s3://testname/access_all.log [part 42 of 64, 15MB]
15728640 of 15728640 100% in 1s 9.31 MB/s done
access_all.log -> s3://testname/access_all.log [part 43 of 64, 15MB]
15728640 of 15728640 100% in 1s 8.94 MB/s done
access_all.log -> s3://testname/access_all.log [part 44 of 64, 15MB]
15728640 of 15728640 100% in 1s 9.45 MB/s done
access_all.log -> s3://testname/access_all.log [part 45 of 64, 15MB]
15728640 of 15728640 100% in 1s 8.73 MB/s done
access_all.log -> s3://testname/access_all.log [part 46 of 64, 15MB]
15728640 of 15728640 100% in 2s 7.40 MB/s done
access_all.log -> s3://testname/access_all.log [part 47 of 64, 15MB]
15728640 of 15728640 100% in 1s 10.56 MB/s done
access_all.log -> s3://testname/access_all.log [part 48 of 64, 15MB]
15728640 of 15728640 100% in 2s 7.19 MB/s done
access_all.log -> s3://testname/access_all.log [part 49 of 64, 15MB]
15728640 of 15728640 100% in 2s 6.95 MB/s done
access_all.log -> s3://testname/access_all.log [part 50 of 64, 15MB]
15728640 of 15728640 100% in 3s 4.76 MB/s done
access_all.log -> s3://testname/access_all.log [part 51 of 64, 15MB]
15728640 of 15728640 100% in 3s 4.23 MB/s done
access_all.log -> s3://testname/access_all.log [part 52 of 64, 15MB]
15728640 of 15728640 100% in 2s 6.26 MB/s done
access_all.log -> s3://testname/access_all.log [part 53 of 64, 15MB]
15728640 of 15728640 100% in 1s 10.70 MB/s done
access_all.log -> s3://testname/access_all.log [part 54 of 64, 15MB]
15728640 of 15728640 100% in 1s 9.83 MB/s done
access_all.log -> s3://testname/access_all.log [part 55 of 64, 15MB]
15728640 of 15728640 100% in 1s 7.84 MB/s done
access_all.log -> s3://testname/access_all.log [part 56 of 64, 15MB]
15728640 of 15728640 100% in 1s 8.55 MB/s done
access_all.log -> s3://testname/access_all.log [part 57 of 64, 15MB]
15728640 of 15728640 100% in 1s 10.49 MB/s done
access_all.log -> s3://testname/access_all.log [part 58 of 64, 15MB]
15728640 of 15728640 100% in 1s 11.16 MB/s done
access_all.log -> s3://testname/access_all.log [part 59 of 64, 15MB]
15728640 of 15728640 100% in 2s 7.25 MB/s done
access_all.log -> s3://testname/access_all.log [part 60 of 64, 15MB]
15728640 of 15728640 100% in 3s 4.06 MB/s done
access_all.log -> s3://testname/access_all.log [part 61 of 64, 15MB]
15728640 of 15728640 100% in 2s 5.84 MB/s done
access_all.log -> s3://testname/access_all.log [part 62 of 64, 15MB]
15728640 of 15728640 100% in 2s 6.10 MB/s done
access_all.log -> s3://testname/access_all.log [part 63 of 64, 15MB]
15728640 of 15728640 100% in 2s 6.10 MB/s done
access_all.log -> s3://testname/access_all.log [part 64 of 64, 11MB]
12569344 of 12569344 100% in 1s 7.63 MB/s done

 

 

 

Ubuntuカテゴリの最新記事