How to download files and folder from s3 bucket using command line

How to download files and folder from s3 bucket using command line
How to download files and folder from s3 bucket using command line


It is very easy to download files and folder from s3 bucket using command line in windows, mac and Ubuntu.

AWS Command Line Interface (AWS CLI)  will help you to download the file and folder from AWS S3 bucket. For more details you can go to official website


Install aws cli on windows

Step1. Go to link and download .msi file 

Step2. Run the downloaded MSI installer or the setup file.

Step3. Now follow the on-screen instructions. By default, the AWS CLI version 1 installs to C:\Program Files\Amazon\AWSCLI .

Step4. To confirm the installation,  open the cmd and put below command

C:\Program Files\Amazon\AWSCLI> aws --version
aws-cli/1.7.24 Python/2.7.9 Windows/8
Step5. We’ve only installed AWS CLI on your PC. To be able to connect to your AWS account, you’ll need one more step.

Note:- To get AWS Access and Secret key, visit to AWS console.

C:\Program Files\Amazon\AWSCLI> aws configure
AWS Access Key ID [None]: JHAIOSFODNN7EXAMPLEAHG
AWS Secret Access Key [None]: njfgtFdsFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
Default region name [None]: us-west-2
Default output format [None]: vetechno
Now you have successfully configured the AWS CLI in you windows machine.
The following command will help you to list the s3 bucket

C:\Program Files\Amazon\AWSCLI> aws s3 ls
Finally we are at the last step to download the file and folder from s3 bucket using command line.

You can download files from S3 either by using cp or sync command on AWS CLI.

aws s3 sync s3://bucketname/dir local directory


OR

aws s3 cp s3://bucketname/dir local directory --recursive

C:\Download>  aws s3 cp s3://bucketname/dir E:\Download --recursive
OR
E:\Download>  aws s3 sync s3://bucketname/dir E:\Download

Conclusion

In this blog post we have learnt how to copy or download folder and file from s3 bucket through command line (cmd). Please let us know in the comment box if you are facing any kind of issue.

Comments

Popular posts from this blog

Failed to establish the VPN connection. This may be caused by a mismatch in the TLS version.

To make SSL VPN connection work, please turn off IE security configuration | vetechno

How to install Mysql 8.0.29 on Ubuntu 22.04 LTS | vetechno