ZacharyST
ZacharyST

Reputation: 676

Use AWS CLI to Copy from S3 to EC2

I have zipped files in an S3 bucket that I need to bring back to my EC2 instance. In the past, I moved the documents to S3 with the following command:

aws s3 cp /my/ec2/path/ s3://my/s3/path/ --exclude '*' --include '2014-01*’ —-recursive

To move files from January 2014 back to EC2, I have tried the following command:

aws s3 cp s3://my/s3/path/ //my/ec2/path/ --exclude '*' --include '2014-01*' --recursive

My understanding is that this command excludes all files but then includes all files with the prefix '2014-01'. I have confirmed that this is how the files I want start. I have also tried only one forward slash before mainstorage and including fewer files.

I have followed these two links from Amazon:

Upvotes: 6

Views: 16600

Answers (1)

ZacharyST
ZacharyST

Reputation: 676

Figured it out. The key was to define the filepath in --include , i.e. --include '2014-1'. Correct command:

aws s3 cp s3://my/s3/path //my/ec2/path/ --exclude '*' --include '*2014-01*' --recursive

Upvotes: 8

Related Questions