【问题标题】:Remove the files in a folder which is present in s3 bucket while doing sync or copy operation from ec2 instance在从 ec2 实例执行同步或复制操作时删除 s3 存储桶中存在的文件夹中的文件
【发布时间】:2019-09-12 07:47:21
【问题描述】:

在我的 ec2 实例中,我有 6 个文件夹,命名为 test1, test2, test3, ..., test6。在我的 s3 存储桶中,我有 10 个名为 test1, ..., test10 的文件夹。我只想将我的本地文件夹同步到 s3 存储桶文件夹。

我的 ec2 中的本地文件夹:

test1 : a.jpg,b.jpg
test2 : c.jpg,d.jpg
test3 : c.jpg,d.jpg
test4 : c.jpg,d.jpg
test5 : c.jpg,d.jpg
test6: e.jpg

但在我的 s3 存储桶中:

test1 : 1.jpg,2.jpg
test2 : 4.jpg,3.jpg
test3 : 5.jpg,6.jpg
test4 : 7.jpg,8.jpg
test5 : 9.jpg,10.jpg
test6 :  11.jpg
test7 : a.jpg,b.jpg
test8 : c.jpg,d.jpg
test9 : c.jpg,d.jpg
test10 : c.jpg,d.jpg

这些文件夹包含不同的文件。我想在 s3 存储桶文件夹中替换这 6 个文件夹的数据。我该怎么做?

如果我使用 aws s3 sync . s3://mybucket/ --delete ,我认为它会删除 s3 存储桶中的剩余文件夹:test7, test8, test9, test10。 我想要我的 s3 存储桶中的所有 10 个文件夹,但只有这 6 个文件夹将具有与 ec2 文件夹中相同的文件。

【问题讨论】:

  • 您是否阅读了aws s3 sync 的文档?它表示,如果您希望在同步期间删除目标中存在但源中不存在的文件,则需要指明 --delete 选项。所以,我认为在这里测试行为并确定它是否是你想要的会很快。

标签: amazon-web-services amazon-s3 amazon-ec2


【解决方案1】:

尝试使用以下命令:

aws s3 cp myDir s3://mybucket/ --recursive

这会将myDir的所有目录复制到S3。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-12
    • 2012-05-14
    • 2019-12-07
    • 2018-05-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多