简体   繁体   中英

<AWS S3> How to download S3 bucket files based on modified date?

I have a use case where I need to download bucket files within a particular modified date range only for diagnosis purpose. There is a large amount of files in the bucket so it is not pracitcal to download all files for the purpose. I have looked at the AWS CLI and it seems there is no readily available S3 options for this (there is only a "--include" option which filters by file name only). May I seek for your advice on this? Thank you

DATE=$(date +%Y-%m-%d)

FILE="$(aws s3api list-objects --bucket bucket_name --query 'Contents[?LastModified>=  `'"$DATE"'`][].{Key: Key}' --output=text| grep file_name)"

aws s3 cp s3://bucket_name/${FILE} .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM