1112

I noticed that there does not seem to be an option to download an entire s3 bucket from the AWS Management Console.

Is there an easy way to grab everything in one of my buckets? I was thinking about making the root folder public, using wget to grab it all, and then making it private again but I don't know if there's an easier way.

4
  • 20
    As many people here said, aws s3 sync is the best. But nobody pointed out a powerful option: dryrun. This option allows you to see what would be downloaded/uploaded from/to s3 when you are using sync. This is really helpful when you don't want to overwrite content either in your local or in a s3 bucket. This is how is used: aws s3 sync <source> <destination> --dryrun I used it all the time before pushing new content to a bucket in order to not upload undesired changes.
    – Perimosh
    Commented Oct 18, 2018 at 16:21
  • Here's a quick video showing aws s3 sync in practice: youtube.com/watch?v=J2aZodwPeQk Commented Apr 1, 2021 at 20:43
  • See 2021/09 complete answer: stackoverflow.com/a/68981037/8718377
    – veben
    Commented Aug 30, 2021 at 8:44
  • For a literal download only... aws s3 cp s3://Bucket/Folder LocalFolder --recursive Commented Oct 4, 2022 at 16:09

42 Answers 42

1965
Answer recommended by AWS Collective

AWS CLI

See the "AWS CLI Command Reference" for more information.

AWS recently released their Command Line Tools, which work much like boto and can be installed using

sudo easy_install awscli

or

sudo pip install awscli

Once installed, you can then simply run:

aws s3 sync s3://<source_bucket> <local_destination>

For example:

aws s3 sync s3://mybucket .

will download all the objects in mybucket to the current directory.

And will output:

download: s3://mybucket/test.txt to test.txt
download: s3://mybucket/test2.txt to test2.txt

This will download all of your files using a one-way sync. It will not delete any existing files in your current directory unless you specify --delete, and it won't change or delete any files on S3.

You can also do S3 bucket to S3 bucket, or local to S3 bucket sync.

Check out the documentation and other examples.

Whereas the above example is how to download a full bucket, you can also download a folder recursively by performing

aws s3 cp s3://BUCKETNAME/PATH/TO/FOLDER LocalFolderName --recursive

This will instruct the CLI to download all files and folder keys recursively within the PATH/TO/FOLDER directory within the BUCKETNAME bucket.

22
  • 315
    First run aws configure and add your access key and secret access key which can be found here. Commented May 17, 2014 at 8:47
  • 14
    Go here for the windows installer aws.amazon.com/cli. It picks up access key id from environment variable "AWS_ACCESS_KEY_ID" and your secret key from "AWS_SECRET_ACCESS_KEY".
    – Matt Bond
    Commented Jul 18, 2014 at 19:03
  • 10
    I've tried s3cmd and Cyberduck, but for me awscli was by far the fastest way to download ~70.000 files from my bucket.
    – Arjen
    Commented Aug 22, 2014 at 7:46
  • 14
    Please note that while the question asked about download only, I believe this command will do a 2-way sync between your directory and S3. If you're not trying to upload anything, make sure the current directory is empty. Commented Nov 26, 2014 at 19:40
  • 20
    @JesseCrossen That aws s3 sync command will not upload anything, but it will delete files locally if they don't exist on S3. See the documentation.
    – Flimm
    Commented Jul 8, 2016 at 12:15
197

You can use s3cmd to download your bucket:

s3cmd --configure
s3cmd sync s3://bucketnamehere/folder /destination/folder

There is another tool you can use called rclone. This is a code sample in the Rclone documentation:

rclone sync /home/local/directory remote:bucket
3
  • 6
    This is quite slow. Especially if you attempt to use it incrementally. Is there a solution that is multi-threaded so it can saturate the bandwidth?
    – Peter Lada
    Commented Oct 8, 2013 at 3:34
  • the solutions below this are better, more standard and open to more platforms
    – abc123
    Commented Dec 11, 2013 at 19:58
  • This does not work for requester pays buckets (see arxiv.org/help/bulk_data_s3) :-( Commented Jun 23, 2014 at 16:08
125

I've used a few different methods to copy Amazon S3 data to a local machine, including s3cmd, and by far the easiest is Cyberduck.

All you need to do is enter your Amazon credentials and use the simple interface to download, upload, sync any of your buckets, folders or files.

Screenshot

6
  • Cyberduck also makes it easy to download public files anonymously - s3cmd seems to require credentials Commented Feb 12, 2014 at 0:57
  • Works great with Transmit too. Commented Feb 7, 2015 at 19:51
  • too slow in comparison to awscli
    – shuboy2014
    Commented Dec 20, 2017 at 18:32
  • cyberduck crashes if having more than 60.000 folders in a bucket
    – Duna
    Commented Feb 4, 2018 at 22:32
  • Another one is Commandeer: getcommandeer.com. It supports S3 file browsing in a normal tree view. Support for downloading files is coming soon! Commented Jul 14, 2019 at 7:05
97

You've many options to do that, but the best one is using the AWS CLI.

Here's a walk-through:

  1. Download and install AWS CLI in your machine:

  2. Configure AWS CLI:

    enter image description here

    Make sure you input valid access and secret keys, which you received when you created the account.

  3. Sync the S3 bucket using:

    aws s3 sync s3://yourbucket /local/path
    

    In the above command, replace the following fields:

    • yourbucket >> your S3 bucket that you want to download.
    • /local/path >> path in your local system where you want to download all the files.
2
  • 1
    I used this instead of cyberduck, because cyberduck needs to "prepare" files before it starts downloading. For large amounts of files that seemed to take ages and I couldn't find information on what "preparing" actually does. CLI started downloading instantly
    – Tashows
    Commented Apr 30, 2019 at 14:26
  • 1
    make sure you have that s3:// prefix in bucket name!!! With aws s3 ls you don't need that s3:// prefix but you need for cp command.
    – cjmling
    Commented Apr 15, 2020 at 12:21
79

To download using AWS S3 CLI:

aws s3 cp s3://WholeBucket LocalFolder --recursive
aws s3 cp s3://Bucket/Folder LocalFolder --recursive

To download using code, use the AWS SDK.

To download using GUI, use Cyberduck.

3
  • 1
    How to ignore some files or folder?
    – Nabin
    Commented Jan 18, 2018 at 3:31
  • 6
    @Nabin you can use --include & --exclude with wildcard to exclude some file or folder, like this: aws s3 cp s3://my-bucket-name ./local-folder --recursive --include "*" --exclude "excludeFolder/*" --exclude "includeFolder/excludeFile.txt" Commented Aug 12, 2018 at 21:24
  • Seems there is no way to exclude or include files while using this command based on user defined meta-data values, i.e. if certain meta-data key value equals value => don't download. Correct ?
    – W.M.
    Commented Nov 28, 2023 at 12:16
56

The answer by @Layke is good, but if you have a ton of data and don't want to wait forever, you should read "AWS CLI S3 Configuration".

The following commands will tell the AWS CLI to use 1,000 threads to execute jobs (each a small file or one part of a multipart copy) and look ahead 100,000 jobs:

aws configure set default.s3.max_concurrent_requests 1000
aws configure set default.s3.max_queue_size 100000

After running these, you can use the simple sync command:

aws s3 sync s3://source-bucket/source-path s3://destination-bucket/destination-path

or

aws s3 sync s3://source-bucket/source-path c:\my\local\data\path

On a system with CPU 4 cores and 16GB RAM, for cases like mine (3-50GB files) the sync/copy speed went from about 9.5MiB/s to 700+MiB/s, a speed increase of 70x over the default configuration.

5
  • 6
    this is the real answer. just tested it, from ec2 it transferred about 2.3GB/min. without the concurrent options about 1GB/min. lifesaver.
    – Karsten
    Commented Mar 1, 2019 at 7:14
  • 1
    This is great! Another tip: for configuring these values for a non-default profile, don't simply replace default with profile-name. Instead use this: aws configure set s3.max_concurrent_requests 1000 --profile profile-name. Commented Mar 22, 2022 at 3:51
  • These settings crashed my browser and stopped the download on my macbook air m1 16gb memory. Had to turn them down a bit. Commented Apr 17, 2023 at 17:54
  • @ChristopherReid, it's not surprising that a large download crashed your browser, these settings should have no effect on a browser anyway, You need to use the CLI or a purpose-built program to download a bucket of any significant size.
    – James
    Commented Apr 18, 2023 at 22:29
  • @James I was using the cli sync commands to download. I was downloading about 90GB of data. While the sync was happening with these settings my browser tabs (firefox) kept crashing. I took a zero/order of magnitude off of each of your recommended settings and it ran fine... but obviously a bit slower. Commented Apr 19, 2023 at 18:36
47

100% works for me, i have download all files from aws s3 backet.

  1. Install AWS CLI. Select your operating system and follow the steps here: Installing or updating the latest version of the AWS CLI

  2. Check AWS version: aws --version

enter image description here

  1. Run config command: aws configure

enter image description here

  1. aws s3 cp s3://yourbucketname your\local\path --recursive

Eg (Windows OS): aws s3 cp s3://yourbucketname C:\aws-s3-backup\yourbucketname --recursive

enter image description here

Check out this link: How to download an entire bucket from S3 to local folder

2
  • 1
    thanks, will it maintain the folder structure inside the bucket?
    – I. Afrin
    Commented May 26, 2021 at 10:29
  • You can also do: aws s3 sync s3://BUCKETNAME/ /Some/local/path/here
    – Gavin
    Commented Jun 11 at 12:16
30

If you use Visual Studio, download "AWS Toolkit for Visual Studio".

After installed, go to Visual Studio - AWS Explorer - S3 - Your bucket - Double click

In the window you will be able to select all files. Right click and download files.

0
26

For Windows, S3 Browser is the easiest way I have found. It is excellent software, and it is free for non-commercial use.

4
  • 4
    I just tried the "Download All Files to..." option (which I presume is equivalent to the "download entire s3 bucket" and it said I need to the Pro version. Commented Aug 11, 2013 at 17:57
  • 3
    Update: But I was able to download an entire folder within the bucket which was sufficient for my needs... Commented Aug 11, 2013 at 18:02
  • yeah the free version is pretty limited, you can select all, and download, but limited to only 2 simultaneous transfers Commented Dec 19, 2015 at 23:24
  • Was looking for a windows simple version after getting some python3 support error on Ubuntu 17.1 and s3cmd, this worked well.
    – edencorbin
    Commented Oct 25, 2017 at 11:06
21

Use this command with the AWS CLI:

aws s3 cp s3://bucketname . --recursive
17

Another option that could help some OS X users is Transmit.

It's an FTP program that also lets you connect to your S3 files. And, it has an option to mount any FTP or S3 storage as a folder in the Finder, but it's only for a limited time.

15

AWS SDK API is only the best option for uploading entire folder and repository to AWS S3 and to download entire AWS S3 bucket locally.

To upload whole folder to AWS S3: aws s3 sync . s3://BucketName

To download whole AWS S3 bucket locally: aws s3 sync s3://BucketName .

You can also assign path like BucketName/Path for particular folder in AWS S3 bucket to download.

13

I've done a bit of development for S3 and I have not found a simple way to download a whole bucket.

If you want to code in Java the jets3t lib is easy to use to create a list of buckets and iterate over that list to download them.

First, get a public private key set from the AWS management consule so you can create an S3service object:

AWSCredentials awsCredentials = new AWSCredentials(YourAccessKey, YourAwsSecretKey);
s3Service = new RestS3Service(awsCredentials);

Then, get an array of your buckets objects:

S3Object[] objects = s3Service.listObjects(YourBucketNameString);

Finally, iterate over that array to download the objects one at a time with:

S3Object obj = s3Service.getObject(bucket, fileName);
            file = obj.getDataInputStream();

I put the connection code in a threadsafe singleton. The necessary try/catch syntax has been omitted for obvious reasons.

If you'd rather code in Python you could use Boto instead.

After looking around BucketExplorer, "Downloading the whole bucket" may do what you want.

1
  • 1
    Unless you need a Java solution use the aws cli answer above. Commented Sep 25, 2014 at 15:23
9

AWS CLI is the best option to download an entire S3 bucket locally.

  1. Install AWS CLI.

  2. Configure AWS CLI for using default security credentials and default AWS Region.

  3. To download the entire S3 bucket use command

    aws s3 sync s3://yourbucketname localpath

Reference to AWS CLI for different AWS services: AWS Command Line Interface

7

If you only want to download the bucket from AWS, first install the AWS CLI in your machine. In terminal change the directory to where you want to download the files and run this command.

aws s3 sync s3://bucket-name .

If you also want to sync the both local and s3 directories (in case you added some files in local folder), run this command:

aws s3 sync . s3://bucket-name
7

To add another GUI option, we use WinSCP's S3 functionality. It's very easy to connect, only requiring your access key and secret key in the UI. You can then browse and download whatever files you require from any accessible buckets, including recursive downloads of nested folders.

Since it can be a challenge to clear new software through security and WinSCP is fairly prevalent, it can be really beneficial to just use it rather than try to install a more specialized utility.

7
aws s3 sync s3://<source_bucket> <local_destination>

is a great answer, but it won't work if the objects are in storage class Glacier Flexible Retrieval, even if the the files have been restored. In that case you need to add the flag --force-glacier-transfer .

7

You can do this with MinIO Client as follows: mc cp -r https://s3-us-west-2.amazonaws.com/bucketName/ localdir

MinIO also supports sessions, resumable downloads, uploads and many more. MinIO supports Linux, OS X and Windows operating systems. It is written in Golang and released under Apache Version 2.0.

6

If you use Firefox with S3Fox, that DOES let you select all files (shift-select first and last) and right-click and download all.

I've done it with 500+ files without any problem.

2
  • This does not work for subfolders within a bucket, even if the "pseudo folders" were created in the AWS console. (As of the writing of this comment)
    – Wesley
    Commented Feb 21, 2013 at 5:25
  • Confirmed not working, I have about 12k top-level keys = subfolders), S3Fox does not even start up. Also insist on the permission to list all buckets!
    – Peter Lada
    Commented Oct 8, 2013 at 3:35
6

You can use sync to download whole S3 bucket. For example, to download whole bucket named bucket1 on current directory.

aws s3 sync s3://bucket1 .
5

In addition to the suggestions for aws s3 sync, I would also recommend looking at s5cmd.

In my experience I found this to be substantially faster than the AWS CLI for multiple downloads or large downloads.

s5cmd supports wildcards so something like this would work:

s5cmd cp s3://bucket-name/* ./folder

2
  • 1
    s5cmd uses golang to be 10x faster than awscli joshua-robinson.medium.com/…
    – vdm
    Commented Aug 29, 2021 at 16:15
  • yes, I don't fully understand the limiting factors in AWS CLI, or why Golang is so much faster than Python (Python GIL limits multi-threading, maybe?) Commented Aug 29, 2021 at 17:04
4

If you have only files there (no subdirectories) a quick solution is to select all the files (click on the first, Shift+click on the last) and hit Enter or right click and select Open. For most of the data files this will download them straight to your computer.

4

Try this command:

aws s3 sync yourBucketnameDirectory yourLocalDirectory

For example, if your bucket name is myBucket and local directory is c:\local, then:

aws s3 sync s3://myBucket c:\local

For more informations about awscli check this aws cli installation

1
  • This piece of art works! This answer link, I am immediately bookmarking. Thanks!
    – Dev_Man
    Commented Aug 12, 2020 at 6:27
4

It's always better to use awscli for downloading / uploading files to s3. Sync will help you to resume without any hassle.

aws s3 sync s3://bucketname/ .
1
  • 1
    What is new in this answer ? Commented Mar 16, 2021 at 10:18
4

When in Windows, my preferred GUI tool for this is CloudBerry Explorer Freeware for Amazon S3. It has a fairly polished file explorer and FTP-like interface.

0
4

Here is a summary of what you have to do to copy an entire bucket:

1. Create a user that can operate with AWS s3 bucket

Follow this official article: Configuration basics

Don't forget to:

  • tick "programmatic access" in order to have the possibility to deal with with AWS via CLI.
  • add the right IAM policy to your user to allow him to interact with the s3 bucket

2. Download, install and configure AWS CLI

See this link allowing to configure it: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-quickstart.html

You can use the following command in order to add the keys you got when you created your user:

$ aws configure
AWS Access Key ID [None]: <your_access_key>
AWS Secret Access Key [None]: <your_secret_key>
Default region name [None]: us-west-2
Default output format [None]: json

3. Use the following command to download content

You can a recursive cp commande, but aws sync command is f:

aws s3 sync s3://your_bucket /local/path

For example, the below command will show all the .png file presents in the bucket. Replay the command without --dryrun to make the resulting files be downloaded.

aws s3 sync s3://your_bucket /local/path --recursive --exclude "*" --include "*.png" --dryrun
4

You just need to pass --recursive & --include "*" in the aws s3 cp command as follows: aws --region "${BUCKET_REGION}" s3 cp s3://${BUCKET}${BUCKET_PATH}/ ${LOCAL_PATH}/tmp --recursive --include "*" 2>&1

3
  1. Windows User need to download S3EXPLORER from this link which also has installation instructions :- http://s3browser.com/download.aspx

  2. Then provide you AWS credentials like secretkey, accesskey and region to the s3explorer, this link contains configuration instruction for s3explorer:Copy Paste Link in brower: s3browser.com/s3browser-first-run.aspx

  3. Now your all s3 buckets would be visible on left panel of s3explorer.

  4. Simply select the bucket, and click on Buckets menu on top left corner, then select Download all files to option from the menu. Below is the screenshot for the same:

Bucket Selection Screen

  1. Then browse a folder to download the bucket at a particular place

  2. Click on OK and your download would begin.

3

just use aws s3 sync command to download all the contents of the bucket. eg : aws s3 sync s3://<bucker name> to <destination/path> note: do aws configure before proceeding

2

aws sync is the perfect solution. It does not do a two way.. it is a one way from source to destination. Also, if you have lots of items in bucket it will be a good idea to create s3 endpoint first so that download happens faster (because download does not happen via internet but via intranet) and no charges

Not the answer you're looking for? Browse other questions tagged or ask your own question.