title: aws s3 sync - how to exclude only certain files from being deleted from s3 during a sync even if they dont exist on local
body: <p>Here is the situation:</p>
  <p>I have a folder containing 5 files in my local repository:
  folder/fileA
  folder/fileB
  folder/fileC
  folder/fileD
  folder/fileE</p>
  <p>And I have the same 5 files on the s3 bucket: myBucketName. The local repository and the aws s3 bucket are in sync. What I want to accomplish is this:</p>
  <ol>
  <li><p>If I add any file manually to the s3 bucket and NOT locally, I DO NOT want this file to be deleted from S3 upon sync.</p>
  </li>
  <li><p>If I delete any file from S3, I DO NOT WANT that file to be deleted from local.</p>
  </li>
  <li><p>If I add a file to my local repository, I want the sync to add the file to S3 via the sync.</p>
  </li>
  <li><p>If I delete a file from my local repository, I want it to be deleted from S3 via the sync.</p>
  </li>
  </ol>
  <p>So I now add the following to aws s3 myBucketName:</p>
  <p>folderB/fileA
  folderB/fileB
  folderB/fileC
  folderB/fileD
  folderB/fileE</p>
  <p>If I do sync now, it recognizes that folderB/* exists on s3 but not on local so it deletes it from s3. I DO NOT WANT this behavior. So essentially I want the sync to happen but ignore the delete operation for folderB/*</p>
  <p>Is there a way for me to accomplish all 4 scenarios using one aws s3 sync command?</p>
  <p>Currently this is what I have:</p>
  <p>aws s3 sync localDirectory s3://myBucketName/ <br />
  --delete <br />
  --exclude &quot;.*&quot; \</p>
  <p>What should I change this to to accomplish the above scenarios?</p>