HomeLinuxDownloading Folders From AWS S3 Bucket cp vs sync

Downloading Folders From AWS S3 Bucket cp vs sync


Amazon gives Easy Storage Service to retailer limitless knowledge on the cloud with full safety and secrecy. It permits the consumer to obtain and add the information on it utilizing the administration console and AWS Command Line Interface (CLI) instructions like “sync” and “cp”.

This information will clarify the downloading of folders from the AWS S3 bucket utilizing AWS CLI instructions.

Downloading Folders From AWS S3 Bucket cp vs sync

There are two instructions to obtain recordsdata from the AWS S3 bucket which can be “sync” and “cp”. “sync” command downloads the updates within the folder from the AWS S3 bucket. Then again, the “cp” command merely copies all recordsdata positioned on the AWS S3 bucket and pastes them into the native folder. The “cp” command downloads all recordsdata no matter their availability within the native listing. Whereas the “sync” solely downloads the recordsdata which were up to date or not already downloaded to the native folder.

Find out how to Obtain S3 Folder?

Comply with these steps to learn to obtain folders accessible on the S3 bucket utilizing AWS CLI instructions.

Step 1: Add the Folder to S3 Bucket

Create an S3 bucket after which head into it to click on on the “Add” button:

Click on on the “Add folder” or drag and drop the folder from the system to the S3 bucket:

Click on on the “Add” button:

Head contained in the folder by clicking on its identify:

Listed here are the recordsdata uploaded on the S3 bucket:

Step 2: Confirm and Configure AWS CLI

Confirm the set up of the AWS CLI by typing this:

Operating the above command will show the aws-cli/2.0.30 model:

Configure the AWS CLI utilizing the next command:

Because of this, you’ll be immediate to supply IAM credentials:

Step 3: Use of “sync” Command

Head into the folder wherein the recordsdata ought to be downloaded:

Use the next syntax and alter the <S3Bucket> to the identify of your bucket to obtain the folder from S3 bucket:

aws s3 sync s3://<S3Bucket> .

In our case, the next command is used to obtain the folder from the S3 bucket:

aws s3 sync s3://upload31 .

It may be noticed that the recordsdata have been downloaded to the native listing:

Now, let’s add one other file into the S3 bucket:

Drag the file and drop it onto the S3 bucket:

Click on on the “Add” button:

The file has been added to the folder:

Use the next command to obtain the newly added file:

aws s3 sync s3://upload31 .

Operating the above command will solely obtain the “demo.csv” file:

The file has been downloaded to the native listing:

Step 4: Use “cp” Command

Syntax for utilizing the “cp” command is talked about under:

aws s3 cp s3://Bucket/Folder LocalFolder –recursive

Change the <Bucket> to the S3 bucket identify, <Folder> to the folder uploaded on the bucket, and <LocalFolder> to the native listing the place the recordsdata can be downloaded:

aws s3 cp s3://upload31/File cp –recursive

The recordsdata have been downloaded from the S3 bucket to the native listing:

Once more, use the identical command to obtain S3 folder:

aws s3 cp s3://upload31/File cp –recursive

Operating the above command will once more obtain all of the recordsdata accessible on the folder:

This information has defined the method of downloading folders from S3 bucket utilizing “cp” or “sync” command.

Conclusion

There are two strategies to obtain folders from the AWS S3 bucket utilizing AWS CLI instructions which can be “cp” and “sync” instructions. The sync command will obtain the up to date recordsdata from the final obtain whereas, the cp command will all the time obtain every file accessible within the folder. This information has defined the method of downloading folders from an S3 bucket utilizing the cp and sync instructions.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments