how to exclude the folder from aws s3 sync command how to exclude the folder from aws s3 sync command shell shell

how to exclude the folder from aws s3 sync command


I believe you'll need to also use the --include flag in your command (see docs for reference)

aws s3 sync --include "*" --exclude "upload/*" --exclude "upload_qa/*" cdn/ s3://cdn-accountname/qa/sitename

Be careful the order

When there are multiple filters, the rule is the filters that appear later in the command take precedence over filters that appear earlier in the command

Tested this out and working fine

home [~]: aws s3 ls s3://abc-fe-testing1                           PRE folder1/                           PRE folder2/                           PRE folder3/                           PRE folder4/home [~]: aws s3 ls s3://abc-fe-testing2home [~]: aws s3 sync s3://abc-fe-testing1 s3://abc-fe-testing2 --exclude "folder1*" --exclude "folder2*"copy: s3://abc-fe-testing1/folder4/file_from_folder4.txt to s3://abc-fe-testing2/folder4/file_from_folder4.txtcopy: s3://abc-fe-testing1/folder3/file_from_folder3.txt to s3://abc-fe-testing2/folder3/file_from_folder3.txthome [~]: aws s3 ls s3://abc-fe-testing2                           PRE folder3/                           PRE folder4/