amazon-web-servicesamazon-s3s3cmd

Exclude multiple folders using AWS S3 sync


How to exclude multiple folders while using aws s3 sync ?

I tried :

    # aws s3 sync s3://inksedge-app-file-storage-bucket-prod-env \ 
                  s3://inksedge-app-file-storage-bucket-test-env \
                  --exclude 'reportTemplate/* orders/* customers/*'

But still it's syncing the folder "customer"

Output :

    copy: s3://inksedge-app-file-storage-bucket-prod-env/customers/116/miniimages/IMG_4800.jpg
       to s3://inksedge-app-file-storage-bucket-test-env/customers/116/miniimages/IMG_4800.jpg

    copy: s3://inksedge-app-file-storage-bucket-prod-env/customers/116/miniimages/DSC_0358.JPG
       to s3://inksedge-app-file-storage-bucket-test-env/customers/116/miniimages/DSC_0358.JPG

Solution

  • At last this worked for me:

    aws s3 sync s3://my-bucket s3://my-other-bucket \
                --exclude 'customers/*' \
                --exclude 'orders/*' \
                --exclude 'reportTemplate/*'  
    

    Hint: you have to enclose your wildcards and special characters in single or double quotes to work properly. Below are examples of matching characters. for more information regarding S3 commands, check it in amazon here.

    *: Matches everything
    ?: Matches any single character
    [sequence]: Matches any character in sequence
    [!sequence]: Matches any character not in sequence