6

I want to calculate bucket size of minio. is it possible to calculate storage quota using MinioClient? or is there any best way to calculate bucket size of minio storage.

thanks in advance

shiva
  • 75
  • 1
  • 7

5 Answers5

8

Yes we can.

first
Downlaod the client e.g. https://dl.min.io/client/mc/release/linux-amd64/mc or any other OS you have

second
set the proper configuration which you need:

  • end-point e.g. https://s3-buket.example.com
  • access-key e.g. jgDbxCy9Uv35sQ7H
  • secret-key e.g. EQqSA5OZLVYqZSztbgq28Seezn9pkX4V

and set it:

minmc alias set s3p https://s3-buket.example.com 'jgDbxCy9Uv35sQ7H' 'EQqSA5OZLVYqZSztbgq28Seezn9pkX4V'
  • minmc MinIO client
  • alias set options
  • s3p a name

after running it we will see:

Added `s3p` successfully.

third
then you can run / use mc sub-command e.g. ls , du , etc

here is a screenshot

enter image description here


source

Shakiba Moshiri
  • 21,040
  • 2
  • 34
  • 44
7

You can do something like this:

mc ls -r --json your_bucket_path | awk '{ FS=","; print $4 }' | awk '{ FS=":"; n+=$2 } END{ print n }'
mikijov
  • 1,552
  • 24
  • 37
  • 2
    Or using jq instead of awk: `mc ls -r --json your_bucket_path | jq -s 'map(.size) | add'` – Jeff Oct 28 '20 at 19:46
3

Inspired by @mikijov, but using jq instead of awk:

mc ls -r --json your_bucket_path | jq -s 'map(.size) | add'
Jeff
  • 856
  • 7
  • 13
2

Show human-readable size:

mc ls -r --json your_bucket_path | jq -s 'map(.size) | add' | numfmt --to=iec-i --suffix=B --padding=7
LONGMAN
  • 980
  • 1
  • 14
  • 24
1

The minio client mc as of version 2019-08-14T20-49-49Z has a du subcommand that can be used as follows to determine the size of a bucket:

mc du --depth 1 <alias>/your_bucket_path

where <alias> is a configuration for an S3 endpoint in accordance with the mc documentation.

Jeff
  • 856
  • 7
  • 13