How to find total size of a s3 bucket or folder in s3 bucket?

How to check the size of a s3 bucket or size of a file in S3 bucket?

The s3cmd tools provide a way to get the total file size of a s3 bucket using “s3cmd du”

See the example below , below command list all buckets in your account

1 2 3 4 5 6 7 8   [root@test.test.com root]$ [root@test.test.com root]$ s3cmd ls 20150623 09:11 s3://neyear1-test/ 20150928 12:45 s3://neyear1-test1/ 20150924 05:15 s3://neyear1-test2/ [root@test.test.com root]$  

Now let us find the size of a s3 bucket “neyear1-test”

1 2 3 4 5   [root@test.test.com root]$ s3cmd du s3://neyear1-test/ 107445352 26 objects s3://neyear1-test/ [root@test.test.com root]$  

Output shows the total size is 107445352 bytes ( 0.107GB) and it contains total 26 Objects

Now let us find the size of a folder “shor” in s3  bucket “neyear1-test” , use the following

1 2 3 4 5   [root@test.test.com root]$ s3cmd du s3://neyear1-test/shor/ 15146 4 objects s3://neyear1-test/shor/ [root@test.test.com root]$  

To find the size of a file in s3 bucket

1 2 3 4 5   [root@test.test.com root]$ s3cmd du s3://neyear1-test/reqal.csv.gz 599875 1 objects s3://neyear1-test/reqal.csv.gz [root@test.test.com root]$  

How to find the s3 bucket size using “aws cli” ?

The “aws cli” tool provides a better way to find the size of the s3 bucket 

1 aws s3 ls summarize humanreadable recursive s3://bucket-name/

You can also mention the folder  ( prefix infact) name

1 2 aws s3 ls summarize humanreadable recursive s3://bucket-name/directory  

 Official documentation is here . please check it out

Author: , 0000-00-00