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
On linux box that have python
(with pip
installer), grep
and awk
, install AWS CLI (command line tools for EC2, S3 and many other services)
sudo pip install awscli
then create a .awssecret
file in your home folder with content as below (adjust key, secret and region as needed):
[default]
aws_access_key_id=
aws_secret_access_key=
region=
Make this file read-write to your user only:
sudo chmod 600 .awssecret
and export it to your environment
export AWS_CONFIG_FILE=/home//.awssecret
then run in the terminal (this is a single line command, separated by \
for easy reading here):
aws s3 ls s3:///foo/bar | \
grep -v -E "(Bucket: |Prefix: |LastWriteTime|^$|--)" | \
awk 'BEGIN {total=0}{total+=$3}END{print total/1024/1024" MB"}'
aws
part lists the bucket (or optionally a 'sub-folder')grep
part removes (using -v
) the lines that match the Regular Expression (using -E
). ^$
is for blank line, --
is for the separator lines in the output of aws s3 ls
awk
simply add to total
the 3rd colum of the resulting output (the size in KB) then display it at the endNOTE this command works for the current bucket or 'folder', not recursively