Bulk Download Files from Amazon S3 Bucket using the AWS CLI Command

  • Last updated Apr 25, 2024

In this tutorial, you will learn how to download multiple files from an Amazon S3 bucket to your local directory using the AWS CLI command.

  1. The initial step is to verify whether the AWS CLI is installed on your computer by executing the following command:
  2. aws --version

    If the AWS CLI is already installed, the above command will display the version number. If it isn't already installed, go to https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html to install it.

  3. Open to edit the AWS credentials profile file on your local system which is located at:
    1. ~/.aws/credentials on Linux, Ubuntu, Mac, or Unix.
    2. C:\Users\username\.aws\credentials on Windows.
    3. Put the following AWS credentials in the AWS credentials profile file:

      aws_access_key_id = YOUR_AWS_ACCESS_KEY_ID
      aws_secret_access_key = YOUR_SECRET_ACCESS_KEY
      region= YOUR_AWS_REGION

      Replace the values of YOUR_AWS_ACCESS_KEY_ID, YOUR_SECRET_ACCESS_KEY, and region with your own AWS credentials.

  4. Next, open a terminal and navigate to the directory where you want the s3 files to be downloaded, then execute the following command:
  5. aws s3 sync s3://bucket-name/folder-name .

    The dot (.) in the above command indicates the origin on your local system from which files should be uploaded to the AWS S3 bucket.