huruyosi’s blog

プログラミングとかインフラとかのメモです。

linkstation LS220D に s3cmd をインストールする

ほぼコピペ qiita.com

ssh でのログインは 別記事を参考にしてください。

huruyosi.hatenablog.com

pipのインストール

setuptools

% wget https://pypi.python.org/packages/source/s/setuptools/setuptools-6.0.2.tar.gz --no-check-certificate
% tar zxfv setuptools-6.0.2.tar.gz
% cd setuptools-6.0.2
% python setup.py install

pip

% wget https://pypi.python.org/packages/source/p/pip/pip-1.5.6.tar.gz --no-check-certificate
% tar zxfv pip-1.5.6.tar.gz
% cd pip-1.5.6
% python setup.py install

s3cmdをインストール

% pip install python-dateutil
% pip install http://sourceforge.net/projects/s3tools/files/s3cmd/1.5.0-rc1/s3cmd-1.5.0-rc1.tar.gz/download

s3cmd でアップロードする

AWSのコンソールでアカウント作成

IAMで専用のユーザを作成しました。 ポリシーグループは AmazonS3FullAccessを割り当てました。 操作途中でアクセスキー、セキュリティキーを控えておきます。

s3cmd --configure

# 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. Leave them empty for using the env variables.
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:

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: *** アクセスキー ***
  Secret Key: *** シークレットキー **
  Encryption password: *** パスワード ***
  Path to GPG program: None
  Use HTTPS protocol: True
  HTTP Proxy server name:
  HTTP Proxy server port: 0

Test access with supplied credentials? [Y/n] y
Please wait, attempting to list all buckets...
Success. Your access key and secret key worked fine :-)

Now verifying that encryption works...
Not configured. Never mind.

Save settings? [y/N] y
Configuration saved to '/root/.s3cfg'

s3cmdでバケットにアクセスする

# s3cmd ls
2015-06-27 11:41  s3://バケット名

s3にアップロード

s3cmd put --encoding=UTF-8 -r /mnt/array1/* s3://バケット名/

mdadmでRAID1になっているマウントポイントの配下のディレクトリを丸ごとs3にアップロードします。 リンクステーションのWeb設定から共有を作成した覚えが無いディレクトリもありますが、製品で必要なものだと思うので、まるっとアップロードします。

オプションの--encoding=UTF-8 がないと漢字のファイル名が?になってしまいます。