Sync files from local filesystem with S3 – one way

amazon s3amazon-web-servicess3cmdsynchronization

I have a process that generates log files to the local filesystem, and files that are more than 2 weeks old are automatically purged. I want to use the aws command line tools to sync my folder with S3, with the following behavior:

  • No sync of files from S3 to local
  • Files are not deleted on S3 when they are purged on the local filesystem.

How does S3 sync work in this way?

Best Answer

Just use the AWS cli:

$ aws s3 cp --recursive /path/to/local/files/* s3://bucket/

Use a set of IAM credentials that has write-only access to the bucket, so that you can be ensured that no files are ever copied back to the source system.