Copy folder from AWS S3

How could we copy a folder from AWS S3 to local machine using AWS CLI?

Use cp command

We can use cp command to copy folder or file from S3 to local machine. If we add parameter --recursive then we will get folder with all its files and folder inside. Example:

aws s3 cp s3://bucketname/foldername localdirname --recursive

This will copy folder foldername with all its content inside from S3 to local folder named localdirname.

Use sync command

We have also sync command that will, by default, copy a whole directory. But it will only copy new and modified files. Unchanged files remain untouched. Example:

aws s3 sync s3://bucketname/foldername localdirname

This will synchronize S3 folder foldername with local folder localdirname.

Tags// ,