s3cmd icon indicating copy to clipboard operation
s3cmd copied to clipboard

Feature request: --delete-excluded

Open mgla opened this issue 9 years ago • 3 comments

When using s3 sync, the parameter --delete-removed works as expected. But when using the parameter --exclude, --rexclude, --exclude-from or --rexclude in combination with --delete-removed, it is currently impossible to remove the excluded files from the remote automatically.

It would be very helpful to have a parameter like that in the future.

mgla avatar Nov 22 '16 09:11 mgla

Thank you for your comment. But to me it looks like a really specific use case. As most of the time, if someone exclude a folder/file, it doesn't want any operation being performed on it. It would probably be better on your case to do a second pass with a include of these folders.

fviard avatar Dec 07 '16 13:12 fviard

I already see this behavior and I don't want it.

I have files in my exclude-from list and when using --delete-removed it still deletes remote files even though they are in my exclude-from. How can I stop that?

using: -r --delete-removed --exclude-from '.gzs' ...

cat .gzs
js/slideshow.js.gz
js/slideshow.js
js/mootools.js.gz
js/mootools.js

Deletes js/mootools.js on s3 because not existing locally even though I have excluded it.

I would suggest both functions can be made available by making the --delete-removed dependent on order. If specified before the --exclude then it should not delete when excluded. But when specified after the --exclude it overrides and does delete. Right now, I tried both ways and it always deleted.

And even when I create a dummy zero byte local file js/mootools.js it deleted on s3. So my guess is that the md5 test is overriding the exclude code when a deleted file is local.

This is driving me nutty because I am trying to get it to not delete remote files when I have upload a gzip encoded version without .gz extension as substitute but it wants to delete them - so I have to upload both even though .gz one is never used. It even goes further and deletes the s3 files when they have the same md5 as the .gz local version - different filename but removes it. Grrr.

And before saying it, even using --no-check-md5 causes it to delete files when md5 matches but filename is different.


Ok. That last point pushed me too far and I went looking at my version of s3cmd because I thought this must be out dated buggy behavior. I found that I had an old Ubuntu repo version installed. But I knew I had pip installed the most recent one. So I realized in this directory I was picking up the old version but in another one I was picking up the pip version because it was set for pyenv to override. Gasp. So I removed the repo one and pip installed globally the new one. Now it works as expected and does not delete excluded files. Yay!

So disregard my rant small rant, but if anyone sees weird behavior this is a good thing to check for.

neocogent avatar Jan 14 '17 07:01 neocogent

rsync provides --delete-excluded for this purpose.

eighthave avatar Dec 12 '23 13:12 eighthave