Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

  • http://docs.aws.amazon.com/cli/latest/reference/s3/index.html
  • http://docs.aws.amazon.com/cli/latest/userguide/using-s3-commands.html
like image 467
ZacharyST Avatar asked Apr 16 '14 23:04

ZacharyST


People also ask

How do I transfer files to AWS EC2?

Open a new command prompt and run the following command replacing the fields as needed: scp -P 2222 Source-File-Path user-fqdn @localhost: To copy the entire directory instead of a file, use scp -r before the path. This recursively copies all of the directory's contents to the destination EC2 instance.

How do I transfer data from S3 to EBS?

Apart from using the AWS CLI commands, Windows users can copy files from S3 to EBS volumes by using RDP into a Windows instance. After you connect to the AWS Management Console, you can directly copy files from the S3 Console to your EBS volumes.


1 Answers

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
like image 193
ZacharyST Avatar answered Oct 27 '22 05:10

ZacharyST