Custom Search

Sunday, June 23, 2013

How to use Amazon S3 tool s3cmd

* S3cmd is a command line (CLI) tool for uploading, retrieving and managing data in Amazon S3.

1)
Install s3cmd

#apt-get install s3cmd

2)
Check Version

#s3cmd --version
s3cmd version 1.0.0
* In "s3cmd version 1.0", we need to add 'access' and 'secret access' keys in a file and pass name of that file as argument.
* "s3cmd version 1.5 alpha" has option to pass 'access' and 'secret access' keys as argument.


3)
Create a config file "myconf.txt" and add 'access' and 'secret access' keys in it.

http://docs.basho.com/riakcs/latest/cookbooks/configuration/Configuring-an-S3-Client/
#vim myconf.txt
access_key = xxxxxxxxxxxxxxxxxx
secret_key = xxxxxxxxxxxxxxxxxxx


4)
List buckets in the default region

#s3cmd -c myconf.txt ls

5)
How to switch region

http://sourceforge.net/p/s3tools/discussion/618865/thread/b3673c09
http://s3tools.org/s3cmd-100rc1-released

* Add following lines into "myconf.txt" to connect to "us-west-1" region.
#vim myconf.txt
host_base = s3-us-west-1.amazonaws.com
host_bucket = %(bucket)s.s3-us-west-1.amazonaws.com


6)
List buckets in the "us-west-1" region

#s3cmd -c myconf.txt ls

7)
How to download the file "alchemy_proj.tar.gz" from the bucket "import-export" in the "us-west-1" region


a)
Prepare config file
#vim myconf.txt
access_key = xxxxxxxxxxxxxxxxxx
secret_key = xxxxxxxxxxxxxxxxxxx
host_base = s3-us-west-1.amazonaws.com
host_bucket = %(bucket)s.s3-us-west-1.amazonaws.com


b)
Command to download file "alchemy_proj.tar.gz" from S3 to local system

#s3cmd -c myconf.txt get s3://import-export/alchemy_proj.tar.gz .
or
#s3cmd -c myconf.txt get s3://import-export/alchemy_proj.tar.gz dest_dir_path

1 comment:

  1. http://s3tools.org/s3cmd

    http://blog.domenech.org/2012/10/using-aws-s3-with-s3cmd.html

    http://techiferous.com/2009/11/using-amazon-s3-from-the-command-line-with-s3sync/

    http://ithubinfo.blogspot.in/2013/05/installing-s3cmd-for-s3-backup-on-amazon.html

    http://docs.basho.com/riakcs/latest/cookbooks/configuration/Configuring-an-S3-Client/

    ReplyDelete