How to copy local files to S3 bucket and copy S3 objects to local

We can copy files to S3 bucket and copy S3 objects to local using aws cli with cp command.

Let us discuss through different requirements and examples.

1. Copy a local file to S3.

#aws s3 cp file.txt s3://mybucket/file.txt

2. Copy files in from a local folder to S3 recursively

#aws s3 cp folder s3://mybucket/ --recursive

3. Copy single object from S3 to local.

#aws s3 cp s3://mybucket/file.txt file.txt

4. Copy S3 objects to local recursively.

#aws s3 cp s3://mybucket . --recursive

5. Copy an S3 object from one bucket to another.

#aws s3 cp s3://mybucket1/file.txt s3://mybucket2/file.txt

6. Copy S3 objects from one bucket to another recursively.

#aws s3 cp s3://mybucket1/ s3://mybucket2/ --recursive

That's all…

Leave a Reply

Your email address will not be published. Required fields are marked *