How to download your S3 bucket to your local Ubuntu development machine using the AWS cli
This minipost will guide you through on how to install the AWS cli and how to configure it in order to download your S3 assets locally. The setup is very simple and all the commands used are detailed and presented step-by-step.
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
Just paste your AWS Access Key ID and your AWS Secret Access Key to the configuration inputs. It’s very important to specify the correct region name of the bucket you are willing to download. As you can see in the below configuration output, I have specified the default region name to eu-central-1
(region: Frankfurt).
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 - do not forget the
.
Your console will start logging, one by one, all the files from the bucket that have been downloaded. The output should look similar to the following:
[..] 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 [..]