Exclude folders for s3cmd sync
Asked Answered
D

2

11

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

for example

bucket
folder/two/
folder/two/file.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/

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

Diluent answered 19/2, 2014 at 19:58 Comment(0)
S
12

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

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 /*/*.

Saveall answered 18/4, 2014 at 12:53 Comment(2)
Hi sylvian thanks this works for me ;) s3cmd --exclude="/*" sync s3://s3bucket local/Diluent
I want to point out that to exclude a specific folder I had to use --exclude="folder/*" instead of --exclude="/folder/*".Lipolysis
A
6

As mentioned by @physiocoder excluding a folder is done the following way:

s3cmd --exclude 'foldername/*'

So that is different from the question but I landed on this page due to its title.

Alphonsoalphonsus answered 1/10, 2015 at 9:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.