We have an AWS s3 sync command that sync's the data from current folder to S3. Below folder structure:
[root@server2022 logs]# ls -ltr
-rw-r--r-- 1 root root 0 Sep 23 13:41 Error-20220921.txt
-rw-r--r-- 1 root root 0 Sep 23 13:41 Error-20220922.txt
-rw-r--r-- 1 root root 0 Sep 23 13:41 Error-20220923.txt
-rw-r--r-- 1 root root 0 Sep 23 13:41 Info-20220922.txt
-rw-r--r-- 1 root root 0 Sep 23 13:41 Info-20220923.txt
We are trying to exclude current date (yyyymmdd format).
aws s3 sync . s3://our-bucket-logs --exclude '*-$(date ' %Y%m%d')*'
Means we are trying to exclude Error-20220923.txt and Info-20220923.txt files (today 20220923).
But none of above commands work and this is continuing to sync to the S3 bucket.
What are we doing wrong?
Updates:
I success to do that using double quotes
aws s3 sync . s3://our-bucket-logs --exclude "*-$(date ' %Y%m%d')*"
CodePudding user response:
You're telling the command that you want to exclude certain files, but then you're telling it you want to include everything.
You should get rid of the --include
option, and you should use double quotes around the --exclude
expression to make sure globbing works:
$ aws s3 sync . s3://our-bucket-logs --exclude "*-$(date ' %Y%m%d')"