Home > Blockchain >  Aws S3 CLI entire folder download to local
Aws S3 CLI entire folder download to local

Time:02-01

Is there a aws cli command that allows to download an entire folder from s3 to local machine, instead of creating a folder locally.

For example , when i run the following command

aws cp s3 s3://<MY-BUCKET>/folder1 . --recursive

I expect the "folder1" to downloaded to my local machine along with its contents.

Thanks in advance

CodePudding user response:

If you want it to copy folder1/, you could use:

aws s3 cp s3://<MY-BUCKET>/ . --recursive --exclude '*' --include 'folder1/*'

This tells it to copy the root directory, but only include folder1/*.

See: AWS CLI - Use of Exclude and Include Filters

CodePudding user response:

You can use the sync method of the s3 cli

aws s3 sync s3://<MY-BUCKET>/folder1 . 

if you really need the folder, you could do something like

mkdir ./folder1
aws s3 sync s3://<MY-BUCKET>/folder1 ./folder1 
  •  Tags:  
  • Related