saurabh
By:
saurabh

Unable to Sync to S3 with s3cmd

May 23, 2015 2.7k views
Backups Python Ubuntu

After setting up s3cmd and my S3 bucket, when I try this command

sudo s3cmd sync --recursive --preserve /srv s3://MyS3Bucket

I get this error:

ERROR: S3 error: 400 (InvalidRequest): The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256.

My s3cmd version is 1.0.0 which is installed by default after following their "deb" installation guide for by Ubuntu 12.04

2 comments
  • I just recently (earlier this week) switched to using S3 buckets with s3fs (sort of like what you are doing but a little different). So far so good. I basically have my S3 buckets mounted as folders, which I then rsync to or use for whatever I need.

    It was fairly easy to set up, except figuring out permissions and users within the Amazon panel. Took me half a day of reading and dinkering around before I learned what I needed to do.

    This walk-through was the one the clued me in the most:

    https://www.caktusgroup.com/blog/2014/11/10/Using-Amazon-S3-to-store-your-Django-sites-static-and-media-files/

  • I'm now able to get through. Upgraded the version of S3CMD from 1.0.0 to 1.5.2.

    Now stuck with the policy thing. I setup one bucket and that shall take care of one VPS and similarly I will create more buckets dedicatedly for other VPS. But I don't want the users of those other VPS to muddle with each other. I am trying to set permissions so that one user has access only to his bucket and that's it. So that other buckets are available in isolation to their users without interference from anyone else.

    Any suggestions?

2 Answers

Another issue now is setting up cron to automate the backup script.

While the commands are working with s3cmd tool when run one by one directly from command line, however when I created a .sh script, and trying to run through cron, the script runs fine but shows below error:

ERROR: S3 error: 400 (InvalidRequest): The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256.

My .sh file is as follows:

#!/bin/sh
echo 'Started'
date +'%a %b %e %H:%M:$S %Z %Y'
s3cmd sync --recursive --preserve /srv s3://MyBucket
s3cmd sync --recursive --preserve /etc s3://MyBucket
s3cmd sync --recursive --preserve /home s3://MyBucket
s3cmd sync --recursive --preserve /var s3://MyBucket
dpkg --get-selections >> dpkg.list 2>&1
s3cmd sync --recursive --preserve dpkg.list s3://MyBucket
date +'%a %b %e %H:%M:$S %Z %Y'
echo 'Finished'

Any suggestions for this?

  • what user are you running the cron under? You might try running the cron as root and see if that helps.

I'm running it through ROOT only.

Anyting other than this that you feel could be affecting the script usage?

Have another answer? Share your knowledge.