Bobcares

Copy file from EC2 to S3- The way we do

by | Apr 22, 2019

In today’s cloud hosting era, Amazon Elastic Compute Cloud (Amazon EC2) is one of the popular ways for developing secure websites.

Even Amazon EC2 instances can fail and affect your websites. Therefore, it’s always a good option to copy files from EC2 to S3 as a backup solution.

That’s why, we often get requests from our customers to copy file from EC2 to S3 as part of our Server Management Services.

Today, we’ll see how our Support Engineers copy file from EC2 to S3.

 

A Quick Glance on Amazon EC2 & S3

First, let’s understand on AWS, Amazon EC2 & Amazon S3.

Amazon Web Services (AWS) is a secure cloud services platform, that offers compute, networking, storage, databases, security and so on. Under the compute domain, there comes the role of Amazon EC2.

With Amazon EC2, users can create instances. In fact, these instances are called virtual machines on AWS infrastructure. It provide users flexibility to choose several varieties of operating systems, RAMs, and CPUs.

For data storage and backup of files, Amazon EC2 uses Amazon S3 which is a repository to store and retrieve any amount of data in case of any failures.

Now, let’s see how we transfer data from EC2 to S3 bucket.

 

How we copy file from EC2 to S3

Usually, we copy a file from EC2 to S3 by executing the below steps.

1. First, we log in to AWS console > IAM dashboard and create groups with S3 full access permission.

2. Then, we log in to EC2 instance and configure AWS in order to identify the security credentials. For this, we execute the following commands.

ssh -i keypair.pem ec2-user@public_ip
sudo -i
aws configure

3. Now, in AWS under My Security Credentials > Access key > Create New Access Key, we create and download a new key pair.

4. Then, copy the Access Key ID and Secret Access Key in the terminal for verification.

5. Next, we list the available S3 buckets.

aws s3api list-buckets

6. After that, we copy the file from EC2 to S3 bucket by using the following command.

aws s3 cp abc.txt s3://bucketname/temp/

7.  Finally, we listed the files in S3 bucket to ensure if the files get uploaded.

aws s3api list-objects --buckets bucketname

 

How we fixed S3 access for a customer

Now, let’s see the common errors that happen while transferring a file from EC2 to S3 bucket.

Recently, one of our customers approached us claiming that when trying to copy files from EC2 to S3 he gets an error like “upload failed: ./file.txt to s3://mybucket/file.txt Unable to locate credentials”.

From our experience, we found that the error happens when the user does not have permission to access the S3 bucket.

So, we fixed the problem by doing the below steps.

1. We logged in to AWS console and choose EC2 instance.

2. Then, we applied the credentials by running the below command.

aws configure

3. And then entered the value for AWS Access Key ID, AWS Secret Access Key, Default region name and Default output format.

4. Thus, the provided credentials for the user was verified.

Now, the customer could copy the file from EC2 to S3 bucket without any fail.

 

[Having trouble while copying a file from EC2 to S3? We can fix it for you.]

 

Conclusion

In short, managing files or restoring data becomes easy with the advanced feature of S3 bucket in Amazon Web Services (AWS). Today, we saw how our Support Engineers copy file from EC2 to S3 and fix the related error.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.