是否有可能从一个S3存储的所有文件复制到另一个s3cmd? [英] Is it possible to copy all files from one S3 bucket to another with s3cmd?
本文介绍了是否有可能从一个S3存储的所有文件复制到另一个s3cmd?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是pretty的满意s3cmd,但有一个问题:如何将所有文件从一个S3存储复制到另一个?它甚至有可能?
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?
编辑:我已经找到一种方法来复制使用Python与博托桶之间的文件:
I've found a way to copy files between buckets using Python with boto:
from boto.s3.connection import S3Connection
def copyBucket(srcBucketName, dstBucketName, maxKeys = 100):
conn = S3Connection(awsAccessKey, awsSecretKey)
srcBucket = conn.get_bucket(srcBucketName);
dstBucket = conn.get_bucket(dstBucketName);
resultMarker = ''
while True:
keys = srcBucket.get_all_keys(max_keys = maxKeys, marker = resultMarker)
for k in keys:
print 'Copying ' + k.key + ' from ' + srcBucketName + ' to ' + dstBucketName
t0 = time.clock()
dstBucket.copy_key(k.key, srcBucketName, k.key)
print time.clock() - t0, ' seconds'
if len(keys) < maxKeys:
print 'Done'
break
resultMarker = keys[maxKeys - 1].key
正在同步几乎是直线前进的复制。有对ETag的,大小字段,以及用于密钥上次修改可用的
Syncing is almost as straight forward as copying. There are fields for ETag, size, and last-modified available for keys.
也许这可以帮助其他人。
Maybe this helps others as well.
推荐答案
s3cmd同步S3://从/本/桶/ S3://来/本/桶/
有关可用选项,请使用:
$ s3cmd --help
For available options, please use:
$s3cmd --help
这篇关于是否有可能从一个S3存储的所有文件复制到另一个s3cmd?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文