Is it possible to copy all files from one S3 bucket to another with s3cmd?

前端 未结 11 1736
陌清茗
陌清茗 2020-12-12 12:30

I\'m pretty happy with s3cmd, but there is one issue: How to copy all files from one S3 bucket to another? Is it even possible?

EDIT: I\'ve found a way to copy files

11条回答
  •  [愿得一人]
    2020-12-12 13:26

    s3cmd won't cp with only prefixes or wildcards but you can script the behavior with 's3cmd ls sourceBucket', and awk to extract the object name. Then use 's3cmd cp sourceBucket/name destBucket' to copy each object name in the list.

    I use these batch files in a DOS box on Windows:

    s3list.bat

    s3cmd ls %1 | gawk "/s3/{ print \"\\"\"\"substr($0,index($0,\"s3://\"))\"\\"\"\"; }"
    

    s3copy.bat

    @for /F "delims=" %%s in ('s3list %1') do @s3cmd cp %%s %2
    

提交回复
热议问题