问题描述
我在S3存储桶中有文件,我试图基于8月8日,9月9日这样的日期下载文件,如何下载选择性的日期文件?我使用了以下代码,但仍会下载整个存储段列表
I have files in S3 bucket, I was trying to download files based on date like 08th aug, 09th Aug, how can I download selective date file?.I used following code but it still downloads entire bucket list
aws s3 cp s3://bucketname/ folder/file --profile pname --exclude \"*\" --recursive --include \"" + "2015-08-09" + "*\"
我不确定如何实现这一目标.
I am not sure, how to achieve this.
推荐答案
此命令将复制以2015-08-15
开头的所有文件:
This command will copy all files starting with 2015-08-15
:
aws s3 cp s3://BUCKET/ folder --exclude "*" --include "2015-08-15*" --recursive
如果您的目标是同步一组文件而不复制两次,请使用sync
命令:
If your goal is to synchronize a set of files without copying them twice, use the sync
command:
aws s3 sync s3://BUCKET/ folder
这将复制自上次同步以来已添加或修改的所有文件.
That will copy all files that have been added or modified since the previous sync.
实际上,这等效于上面的cp
命令:
In fact, this is the equivalent of the above cp
command:
aws s3 sync s3://BUCKET/ folder --exclude "*" --include "2015-08-15*"
参考文献:
- AWS CLI
s3 sync
command documentation - AWS CLI
s3 cp
command documentation
这篇关于在AWS S3 CLI中选择文件下载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!