I’ve spent some time trying various combinations of the AWS S3 cp command in recursive mode, which is used to copy multiple object to and from AWS S3. I also wanted to exclude certain folders from being copied.

Here is my scenario: I have a bucket named S3BUCKET which contains a folder named archive. I want to copy down locally all objects from the root of S3BUCKET, and I want to exclude archive. After many tries, here is a command that worked for me:

aws s3 cp s3://S3BUCKET/ . --exclude "archive/*" --recursive

Note that you can append--dryrun at the end of an aws s3 command to see what it would do without actually running operations against S3.

Grig Gheorghiu

DevOps, cloud computing, Python and Golang programming, data science, automated testing.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store