s3cmd Commandlines3client
s3cmd Commandlines3client
http://s3tools.logix.cz/s3cmd
Important stuff
About S3 tools Download s3cmd Amazon S3 Bug reporting Community, contact Mailing list, Forum
Sections
Articles Documentation News
Stay informed
RSS / Atom
Search
1 of 5
10/29/08 1:51 PM
http://s3tools.logix.cz/s3cmd
data storage needs. Check out our pages about Amazon S3 to find out more. S3cmd is a command line tool for uploading, retrieving and managing data in Amazon S3. It is best suited for power users who don't fear command line. It is also ideal for scripts, automated backups triggered from cron, etc.
You will be asked for the two keys - copy and paste them from your confirmation email or from your Amazon account page. Be careful when copying them! They are case sensitive and must be entered accurately or you'll keep getting errors about invalid signatures or similar. Run s3cmd
ls to
As you just started using S3 there are no buckets owned by you as of now. So the output will be empty. Make a bucket with s3cmd
mb s3://my-new-bucket-name
As mentioned above bucket names must be unique amongst _all_ users of S3. That means the simple names like "test" or "asdf" are already taken and you must make up something more original. I often prefix my bucket names with my e-mail domain name (logix.cz) leading to a bucket name, for instance, 'logix.cz-test':
~$ s3cmd mb s3://logix.cz-test Bucket 'logix.cz-test' created
ls
2 of 5
10/29/08 1:51 PM
http://s3tools.logix.cz/s3cmd
s3://logix.cz-test/addrbook.xml
Retrieve the file back and verify that its hasn't been corrupted
~$ s3cmd get s3://logix.cz-test/addrbook.xml addressbook-2.xml
Object s3://logix.cz-test/addrbook.xml saved as 'addressbook-2.xml' (123456 bytes) ~$ md5sum addressbook.xml addressbook-2.xml 39bcb6992e461b269b95b3bda303addf addressbook.xml 39bcb6992e461b269b95b3bda303addf addressbook-2.xml
Checksums of the original file matches the one of the retrieved one. Looks like it worked :-) Clean up: delete the object and remove the bucket
~$ s3cmd rb s3://logix.cz-test ERROR: S3 error: 409 (Conflict): BucketNotEmpty
Hints
The basic usage is as simple as described in the previous section. You can increase the level of verbosity with -v option and if you're really keen to know what the program does under its bonet run it with -d to see all 'debugging' output. After configuring it with --configure all available options are spitted into your ~/.s3cfg file. It's a text file ready to be modified in your favourite text editor. Multiple local files may be specified for s3cmd put operation. In that case the S3 URI should only include the bucket name, not the object part:
~$ s3cmd put file-* s3://logix.cz-test/ File 'file-one.txt' stored as s3://logix.cz-test/file-one.txt (4 bytes) File 'file-two.txt' stored as s3://logix.cz-test/file-two.txt (4 bytes)
Alternatively if you specify the object part as well it will be treated as a prefix and all filenames given on the command line will be appended to the prefix making up the object name. However --force option is required in this case:
3 of 5
10/29/08 1:51 PM
http://s3tools.logix.cz/s3cmd
~$ s3cmd put --force file-* s3://logix.cz-test/prefixed: File 'file-one.txt' stored as s3://logix.cz-test/prefixed:file-one.txt (4 bytes) File 'file-two.txt' stored as s3://logix.cz-test/prefixed:file-two.txt (4 bytes)
Comment
1. Nikunj wrote: Hi, Is there any convenient way to delete all files under a bucket? I have plenty of files in a bucket. Mentioning wild card characters in the delete command doesnt work too. Thanks! ( 3 October 2008, 19:20 #) 2. Michal wrote: For now I suggest you check out s3cmd trunk from SVN and use recursive delete. For instance: s3cmd del recursive s3://your-bucket/ ( 3 October 2008, 19:23 #) Name E-mail Website Remember
Message
Textile Help
4 of 5
10/29/08 1:51 PM
http://s3tools.logix.cz/s3cmd
Preview
Submit
5 of 5
10/29/08 1:51 PM