排除 s3cmd 同步的文件夹

人气:1,078 发布:2022-09-11 标签: amazon-s3 sync s3cmd

问题描述

我正在使用 s3cmd,我想知道如何排除存储桶中的所有文件夹并同步存储桶根目录.

I am using s3cmd and i would like to know how to exclude all folders within a bucket and just sync the bucket root.

例如

bucket
folder/two/
folder/two/file.jpg
get.jpg

通过同步,我只希望它同步 get.jpg 并忽略文件夹及其内容.

with the sync i just want it to sync the get.jpg and ignore the folder and its contents.

s3cmd --config sync s3://s3bucket (only sync root) local/

如果有人可以提供帮助,那就太棒了,我已经尝试过 --exclude 但不确定如何在这种情况下使用它?

If someone could help that would be amazing i have already tried the --exclude but not sure how to use it in this situation?

推荐答案

您确实应该使用 --exclude 选项.如果你想同步根目录上的每个文件而不是文件夹,你应该尝试:

You should indeed use the --exclude option. If you want to sync every file on the root but not the folders, you should try :

s3cmd --exclude="/*/*" sync local/ s3://s3bucket

请记住,S3 上实际上并不存在文件夹.文件夹 folder 中的文件 file 似乎只是一个名为 folder/file 的文件!所以你只需要排除带有 /*/* 模式的文件.

Keep in mind that a folder doesn't really exist on S3. What seems to be a file file in a folder folder is just a file named folder/file! So you just have to exclude file with the pattern /*/*.

459