- Newest
- Most votes
- Most comments
The behavior you're observing with the aws s3 sync --delete command across different clients is related to how the AWS CLI handles file comparisons during synchronization operations.
By default, the AWS CLI S3 sync command uses both file size and modification time to determine if a file needs to be updated. However, the comparison of modification times works in a specific way that can appear counterintuitive:
-
If the destination file is newer than the source file, the sync command will download/upload the file. This happens because the command assumes that the source version is the "authoritative" version, and any destination file with a more recent timestamp might be out of sync.
-
If the source file is newer than the destination file, the sync command typically won't transfer the file again, assuming the newer source version is already reflected in the destination.
The difference in behavior between your macOS and Rocky Linux clients could be due to several factors:
- Different filesystem timestamp precision or handling between macOS and Linux
- Variations in how the operating systems handle file metadata
- Potential clock synchronization differences between the systems
- Subtle differences in how the AWS CLI interacts with the underlying operating system
To make the behavior more consistent across platforms, you could try using additional flags with your sync command:
- Use
--exact-timestampsto only update files if the timestamps are different - Use
--size-onlyto compare only the size of the files, ignoring timestamps completely
The --delete flag you're using removes files from the destination that don't exist in the source, but the decision about which files to upload/download is still governed by the timestamp and size comparison logic.
This behavior is by design to minimize unnecessary data transfer, but it may not always align with specific use cases across different operating systems.
Sources
aws s3 sync --- downloading older version from source [BUG?] | AWS re:Post
Is AWS CLI really synchronious? | AWS re:Post
You can run the following command to see what will happen when you run sync.
aws s3 sync source/ s3://destination-bucket/ --delete --exact-timestamps --dryrun
Also,
- Confirm whether the metadata of the object has changed or not
- Confirm that you are using same timestamp when calling to S3
Relevant content
asked a year ago
- AWS OFFICIALUpdated 9 months ago

intention update object on destination
A client (dryrun) upload: ./sync_1.jpg to s3://......../sync_1.jpg (dryrun) upload: ./sync_2.jpg to s3://......../sync_2.jpg (dryrun) upload: ./sync_sakje1.jpg to s3://........./sync_sakje1.jpg (dryrun) upload: ./sync_sakje2.jpg to s3://......../sync_sakje2.jpg (dryrun) upload: ./sync_sakje3.jpg to s3://......./sync_sakje3.jpg
B client however B client sync --delete excuting both upload and delete operations simultaneously when source station meta data modified
(dryrun) upload: ../../../../../....../common.css to s3://......./common.css (dryrun) delete: s3://......./common.css
(dryrun) upload: ../../../../../....../fonts/Pretendard-Black.subset.woff to s3://....../fonts/Pretendard-Black.subset.woff (dryrun) delete: s3://......./fonts/Pretendard-Black.subset.woff