AWS CLI S3: copying file locally using the terminal : fatal error: An error occurred (404) when calling the HeadObject operation

Viewed 50977

I'm trying to copy files locally from s3 bucket. I can get the list of files on my bucket:

aws s3 ls  s3://myBucket/myDirectory/todaysFiles/

But when I try to copy the files locally:

aws s3 cp s3://myBucket/myDirectory/todaysFiles/ .

I get this error:

fatal error: An error occurred (404) when calling the HeadObject operation: Key "myDirectory/todaysFiles/" does not exist

But I try to copy just one file locally:

 aws s3 cp s3://myBucket/myDirectory/todaysFiles/somefile .

I get this error:

 warning: Skipping file s3://myBucket/myDirectory/todaysFiles/somefile. Object is of storage class GLACIER. Unable to perform download operations on GLACIER objects. You must restore the object to be able to the perform operation. See aws s3 download help for additional parameter options to ignore or force these transfers.

Any of you knows why I'm getting this error or way around this errors?

I really appreciate your help

4 Answers

Use --recursive at the end if the Source contains multiple folders.

aws s3 cp s3Uri Local --recursive

In case it helps anyone, you can also use

aws s3 sync s3://<bucketname>/<folder>/ ./<folder>

This should work without having to use the recursive. It has the benefit that it skips files already present locally.

As mentioned by @raju, glacier is a cheap storage system on AWS, meaning if you want to retrieve the data you first need to put a request in to fetch the data before you can download it. It's made to be cheap for long term storage that isn't accessed frequently.

Related