usingla
usingla

Reputation: 23

How to get the size of all files in a S3 bucket without versioning?

My bucket size is over 150 TB now and the number of files is over 100k. I am working on a better versioning policy now but I need to know the current size without versions, so I can balance the price and effort with my solution vs moving them to Glacier. I have folders as well as files in it.

Afaik, AWS only exposes the API for getting the total size of a bucket.

Upvotes: 0

Views: 874

Answers (2)

John Rotenstein
John Rotenstein

Reputation: 270144

You can also take advantage of Amazon S3 Inventory - Amazon Simple Storage Service to obtain a detailed listing of the bucket.

Alternatively, you could use Amazon S3 Intelligent-Tiering — a New Amazon S3 Storage Class to do it all for you!

Upvotes: 2

Nay Oo Kyaw
Nay Oo Kyaw

Reputation: 82

aws s3 ls s3://<bucketname> --recursive  | grep -v -E "(Bucket: |Prefix: |LastWriteTime|^$|--)" | awk 'BEGIN {total=0}{total+=$3}END{print total/1024/1024" MB"}'

Upvotes: 4

Related Questions