In my amazon EC2 instance, I have a folder named uploads
. In this folder I have 1000 images. Now I want to copy all images to my new S3 bucket. How can I do this?
After generating the Access key ID and secret access key, log into the EC2 instance using SSH and configure the access key. It will ask for an access key ID and the secret access key. Provide the credentials we just generated. Now the EC2 instance has access to upload the files on S3 using the command line interface.
You have two options for uploading files: AWS Management Console: Use drag-and-drop to upload files and folders to a bucket. AWS CLI: With the version of the tool installed on your local machine, use the command line to upload files and folders to the bucket.
Use s3cmd
s3cmd get s3://AWS_S3_Bucket/dir/file
Take a look at this s3cmd documentation
if you are on linux, run this on the command line:
sudo apt-get install s3cmd
or Centos, Fedore.
yum install s3cmd
Example of usage:
s3cmd put my.file s3://pactsRamun/folderExample/fileExample
Using Cli from amazon
Like @tedder42 said in the comments, instead of using cp
, use sync
.
Take a look at the following syntax:
aws s3 sync <source> <target> [--options]
Example:
aws s3 sync . s3://my-bucket/MyFolder
More information and examples available at Managing Objects Using High-Level s3 Commands with the AWS Command Line Interface
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With