Zimbra offers Open Source email server software and shared calendar for Linux and the Mac
Go Back   Zimbra :: Forums > Zimbra Collaboration Suite > Administrators

Welcome to the Zimbra :: Forums!
Welcome, if you would like to post a comment please register. We also encourage you to explore all things Zimbra with our team and members of the community.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-29-2009, 02:44 PM
Member
 
Posts: 11
Lightbulb Export Mailbox Size to CSV

I wrote a bash script to get mailbox size of all mailboxes and export it to csv. Hopefully someone finds this useful.

I would post it to the wiki put when I created by wiki account I didn't see a create page link.

Code:
#!/bin/bash

#This script exports email address & mailbox size in MB to csv for all accounts
#It was tested against a single domain setup
#For 125 accounts and 300GB total volume size it took about 5 minutes
#By James Barnett james.barnett@noc.com

cd /home/zimbra;

echo "This will take a few minutes ..."

zmprov gaa > temp.txt; #export a list all accounts to a temp file

rm -f size.csv #remove the any pervious CSV file

echo -n "Email Address, " >> size.csv 

echo "Size of Mailbox in MB" >> size.csv #echo column headers to the CSV file

for i in $(cat temp.txt); #loop through the accounts
do
     echo -n "$i, "  >> size.csv; #echo the email address

     bytes=$(zmmailbox -z -m $i getmailboxsize -v) #get mailbox size in bytes and set to variable

     echo "scale=2; $bytes/1048576" | bc>> size.csv #return mailbox size in MB
done

rm -f temp.txt #remove temp file

echo "Finished! Check /home/zimbra/size.csv for results"

echo -e "\a" #Ring the system bell to let the user know the report is ready
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads

Why Join?

Registering let's you ask questions, makes it easier to search, displays any files attached to posts, and notifies you about replies.

blog.zimbra.com




 

SEO by vBSEO ©2011, Crawlability, Inc.