Alright I'm very confused by aws cli
I have an S3 bucket:
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
The AWS CLI provides two tiers of commands for accessing Amazon S3: The s3 tier consists of high-level commands that simplify performing common tasks, such as creating, manipulating, and deleting objects and buckets. The s3api tier behaves identically to other AWS services by exposing direct access to all Amazon S3 API operations.
The s3 tier consists of high-level commands that simplify performing common tasks, such as creating, manipulating, and deleting objects and buckets. The s3api tier behaves identically to other AWS services by exposing direct access to all Amazon S3 API operations.
There was a bug in earlier versions that required the bucket name to be included for include/exclude filters for s3 locations, which is inconsistent with how local file include/exclude works. This has now been fixed and you're example should work on the latest version.
In the command aws s3 sync /tmp/foo s3://bucket/ the source directory is /tmp/foo. Any include/exclude filters will be evaluated with the source directory prepended. Below are several examples to demonstrate this.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With