在同一存储桶上复制S3中的大量文件
我在带有80 tb〜的S3存储桶上有一个“目录”,我需要将所有内容复制到同一存储桶中的另一个目录
source = s3:// mybucket/abc/abc/process/
destiny = s3:// mybucket/cde/process/
我已经尝试使用AWS S3 Sync,但仅用于大文件,仍然留下50 TB进行复制。我正在考虑将BOTO3代码作为下面的示例使用,但是我不知道该如何为多个文件/目录进行递归。
s3 = boto3.resource('s3')
copy_source = {
'Bucket': 'mybucket',
'Key': 'mykey'
}
s3.meta.client.copy(copy_source, 'otherbucket', 'otherkey')
我该如何使用Boto3进行操作?
I got a "directory" on a s3 bucket with 80 TB ~ and I need do copy everything to another directory in the same bucket
source = s3://mybucket/abc/process/
destiny = s3://mybucket/cde/process/
I already tried to use aws s3 sync, but worked only for the big files, still left 50 TB to copy. I'm thinking about to use a boto3 code as this example below, but I don't know how to do for multiple files/directories recursively.
s3 = boto3.resource('s3')
copy_source = {
'Bucket': 'mybucket',
'Key': 'mykey'
}
s3.meta.client.copy(copy_source, 'otherbucket', 'otherkey')
How can I do this using the boto3?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
虽然可能有更好的方法可以使用桶策略来实现Boto3。
首先,您需要获取
source_bucket是bucket的名称的存储桶内容的列表,而source_prefix是文件夹的名称。
接下来,您将在内容上迭代,每个项目都将S3.META.CLIENT.COPY方法称为类似的内容,因此
内容是字典,因此您必须使用“键”获取项目的名称并使用split将其分解为前缀和文件名。
While there may be better ways of doing this using bucket policies, it can be done using boto3.
first you will need to get a list of the contents of the bucket
Where source_bucket is the name of the bucket and source_prefix is the name of the folder.
Next you will iterate over the contents and for each item call the s3.meta.client.copy method like so
the contents are a dictionary so you must use 'Key' to get the name of the item and use split to break it into prefix and file name.