How to move files from amazon ec2 to s3 bucket using command line

前端 未结 7 1280
予麋鹿
予麋鹿 2020-12-24 13:15

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 thi

7条回答
  •  情话喂你
    2020-12-24 13:48

    We do have a dryrun feature available for testing.

    • To begin with I would assign ec2-instance a role to be able read write to S3
    • SSH into the instance and perform the following
    • vi tmp1.txt
    • aws s3 mv ./ s3://bucketname-bucketurl.com/ --dryrun
    • If this works then all you have to do is either create a script to upload all files with specific from this folder to s3 bucket
    • I have done the wrritten the following command in my script to move files older than 2 minutes from current directory to bucket/folder
    • cd dir; ls . -rt | xargs -I FILES find FILES -maxdepth 1 -name '*.txt' -mmin +2 -exec aws s3 mv '{}' s3://bucketurl.com

提交回复
热议问题