#81 Exclude directory not working

s3cmd (118)
Simon Hill

I want to sync a directory but exclude a couple of sub-directories. I've tried the following but none seem to work
For example, I want to sync everything in /webroot except for the directory /webroot/admin

s3cmd sync --dry-run --verbose --encoding UTF-8 --exclude "/webroot/admin/" /webroot/*
s3cmd sync --dry-run --verbose --encoding UTF-8 --exclude "/webroot/admin/*" /webroot/*
s3cmd sync --dry-run --verbose --encoding UTF-8 --exclude "/webroot/admin" /webroot


  • Christian S.
    Christian S.

    After a lot of testing i found a workaround.
    If you write:
    s3cmd sync --exclude "*webroot/admin/*" /webroot
    it works.

    Its not really a solution, but works for me.

  • After doing a lot of testing, I believe I have discovered the issue. The problem is that the --exclude/--include(-from), when converting the values in the these list to regular expression it does not handle the directory name correctly. What I believe it should be doing is replacing a "./" in the file names in list with a "^".

    This would make "./webroot/admin/" "^webroot\/admin\/.*$", when converted to regular expressions. Until this change is made, using the regular expression and manually converting them, will work. This is what I am doing.

  • +1

    This bug took me a while to figure out. Please use the same format as a .gitignore so that "venv" will exclude the whole "venv" directory.

    In the mean time, you can change your directory exclusions to the "venv/*" format, which will work correctly.