AWS S3: how do I see how much disk space is using

前端 未结 18 1389
被撕碎了的回忆
被撕碎了的回忆 2020-12-12 10:33

I have AWS account. I\'m using S3 to store backups from different servers. The question is there any information in the AWS console about how much disk space is in use in my

18条回答
  •  北荒
    北荒 (楼主)
    2020-12-12 10:54

    Based on @cudds's answer:

    function s3size()
    {
        for path in $*; do
            size=$(aws s3 ls "s3://$path" --recursive | grep -v -E "(Bucket: |Prefix: |LastWriteTime|^$|--)" | awk 'BEGIN {total=0}{total+=$3}END{printf "%.2fGb\n", (total/1024/1024/1024)}')
            echo "[s3://$path]=[$size]"
        done
    }
    
    ...
    
    $ s3size bucket-a bucket-b/dir
    [s3://bucket-a]=[24.04Gb]
    [s3://bucket-b/dir]=[26.69Gb]
    

    Also, Cyberduck conveniently allows for calculation of size for a bucket or a folder.

提交回复
热议问题