amazon s3 - Downloading from S3 with aws-cli using filter on specific prefix -
for reason there's bucket bunch of different files, of have same prefix different dates:
backup.2017-01-01aa
backup.2017-01-01ab
backup.2017-01-15aa
backup.2017-01-15ab
backup.2017-02-01aa
backup.2017-02-01ab
etc..
how download only files start "backup.2017-01-01"?
you'll have use aws s3 sync s3://yourbucket/
there 2 commands can give aws s3 sync; --exclude , --include, both of can take "*" wildcard.
first we'll have --exclude "*"
exclude of files, , we'll --include "backup.2017-01-01*"
include files want specific prefix. can change include around --include "*-01-01*"
.
that's it, here's full command:
aws s3 sync s3://yourbucket/ . --exclude "*" --include "backup.2017-01-01*"
also, remember use --dryrun
test command , avoid downloading files in bucket.
Comments
Post a Comment