Question:
Alright I’m very confused by aws cli
I have an S3 bucket:
1 2 3 4 5 6 7 |
s3://my-bucket directory/ file1 file2 backup-logs-1234 backup-logs-5678 |
I’ve verified that the files are in the s3 bucket, and I can see them with aws s3 ls s3://my-bucket
I’m trying to delete all the backup logs in the folder (8000 of them). I’ve tried every combination of includes/excludes I can think of
1) For some reason aws s3 rm "s3://my-bucket/" --include "*backup-logs*" --dryrun
tries to delete s3://my-bucket/directory/
2) aws s3 rm "s3://my-bucket/" --exclude "*" --include "*backup-logs*" --dryrun
doesn’t see any files to delete
3) I’ve also tried different substrings of “backup” (eg. b, ba, back)
4) I’ve also tried adding recursive (even though I don’t want it to be) and it finds all the files in directory/
that match the pattern, but none of the top level ones
I’m sure I’m doing something stupid. Thanks in advance for the help
Answer:
aws s3 rm s3://my-bucket/ --recursive --exclude "*" --include "*backup-logs*"
should work.
When you want to delete multiple objects within your bucket
–recursive (boolean) Command is performed on all files or objects
under the specified directory or prefix.
You can read on http://docs.aws.amazon.com/cli/latest/reference/s3/index.html#use-of-exclude-and-include-filters about include/exclude use