Introduction

AWS S3 CLI provides two different commands that we can use to download an entire S3 Bucket.

The commands are:

  • cp
  • sync

Using cp

cp can download all the files from the bucket to your local folder. If there are multiple folders in the bucket, you can use the --recursive flag.

The command you would use to copy all the files from a bucket named my-s3-bucket to your current working directory:

aws s3 cp s3://my-s3-bucket/ . --recursive

If you want to learn more about how to use the cp command, check out our tutorial that goes into more detail.

Using sync

  • Sync will only copy new and updated files from the source directory to the destination. Sync will first look at the destination folder before copying files over.

  • --delete flag supports the deletion of files in the destination folder but no longer in the source folder. sync compares the size of the file and the last modified timestamp to check if a file needs updating. Sync doesn’t compare file contents.

The command you would use to download an S3 bucket:

aws s3 sync s3://my-s3-bucket .