Last Updated on February 9, 2022 by Vikash Ekka
|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 FilesAmazonAWSCLI .
Step4. To confirm the installation, open the cmd and put below command
C:Program FilesAmazonAWSCLI> 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 FilesAmazonAWSCLI> 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 FilesAmazonAWSCLI> 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
aws s3 cp s3://bucketname/dir local directory –recursive
C:Download> aws s3 cp s3://bucketname/dir E:Download --recursive
E:Download> aws s3 sync s3://bucketname/dir E:Download