Skip to content

Instantly share code, notes, and snippets.

@aloucaslabs
Created February 6, 2019 15:03
Show Gist options
  • Save aloucaslabs/794ef0446178dc9c3568a7b6aae78f53 to your computer and use it in GitHub Desktop.
Save aloucaslabs/794ef0446178dc9c3568a7b6aae78f53 to your computer and use it in GitHub Desktop.
How to download your S3 bucket to your local ubuntu development machine using the AWS CLI. (Source: https://www.aloucaslabs.com/miniposts/how-to-download-your-s3-bucket-to-your-local-ubuntu-development-machine-using-the-aws-cli)

How to download your S3 bucket to your local ubuntu development machine using the AWS CLI

The first thing to do, is to make sure that your Ubuntu system is up to date, type:

$ sudo apt-get update && sudo apt-get -y upgrade

Then, download and install the python pip that is required to install the AWS cli, type:

$ sudo apt-get install python-pip

When the download finishes, you are ready to download and install the AWS cli, type:

$ pip install awscli

When the installation is finished, it’s time to configure your AWS cli, type:

$ aws configure

Configuration:

AWS Access Key ID: <Your AWS Access Key ID>
AWS Secret Access Key: <Your AWS Secret Access key>
Default region Name : <eu-central-1> 
Default output format: None

Having finished the configuration, you are ready to download your S3 bucket with the following command:

$ aws s3 sync s3:/BUCKET_NAME .
  • replace BUCKET_NAME with the actual name of the S3 bucket to download
  • don't forget the . 

Your console output should be similar

[..]
download: s3://BUCKET_NAME/uploads/photo_attachment/file_name/138/administration_tiny_post.jpg to uploads/photo_attachment/file_name/138/administration_tiny_post.jpg
download: s3://BUCKET_NAME/uploads/photo_attachment/file_name/138/administration_thumb_post.jpg to uploads/photo_attachment/file_name/138/administration_thumb_post.jpg
[..]

Commands extracted from how to download your S3 bucket locally using the AWS cli

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment