5
5

More than 5 years have passed since last update.

さくらのレンタルサーバにs3cmdを導入する

Last updated at Posted at 2015-02-02

バックアップに使いたいですよね。 root 権限がなく、他のサイトで書かれているやり方ではうまくいかなかったため簡単に手順を書いてみます(ぼくは Python 歴 30 分ぐらいなので理解の整理もかねて……)。

s3cmd を git からとってきます。

% git clone https://github.com/s3tools/s3cmd.git

実行したところ、エラーになりました。

% ./s3cmd

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ImportError trying to import dateutil.parser.
Please install the python dateutil module:
$ sudo apt-get install python-dateutil
  or
$ sudo yum install python-dateutil
  or
$ pip install python-dateutil
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

python-dateutil 入れろと言われました。 root 権限がなく、また、デフォルトで pip が使えないので easy_install を使って python-dateutil を入れてみます。

まず ~/.pydistutils.cfg を作成し、下記のように指定します。すると、 easy_install でユーザディレクトリに保存されるようになるらしいです。

~/.pydistutils.cfg
[install]
user=1

次に、 easy_install します。

% easy_install python-dateutil

再挑戦

% ./s3cmd
ERROR: /home/.s3cfg: Operation not permitted
ERROR: Configuration file not available.
ERROR: Consider using --configure parameter to create one.

通りました。あとはいつもの通り .s3cfg を作るなりして使えると思います。

python-magic があると MIME タイプを判断してくれ、これがないと WARNING が出てしまうのでこちらも入れておくといいでしょう。

% easy_install python-magic

(おまけ)Ansible Playbook の Task をこんなかんじでつくってみました。

s3cmd.yml
---
- copy: src=files/pydistutils.cfg dest=~/.pydistutils.cfg
- easy_install: name={{ item }}
  with_items:
    - python-dateutil
    - python-magic
- git: repo=https://github.com/s3tools/s3cmd.git dest=~/bin/repos/s3cmd
    accept_hostkey=yes
- file: src=~/bin/repos/s3cmd/s3cmd dest=~/bin/s3cmd state=link
- template: src=templates/s3cfg.j2 dest=~/.s3cfg mode=0400

参考文献

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