Wednesday, March 3, 2010

Distribution lists in Zimbra

Collect the Distribution lists/groups from your zimbra server to a file.

---------------------------------------------------------------------
#!/bin/bash
#Declare name of output file in the variable below:
file=dscripttest;
echo "" > $file;
for line in `zmprov gadl`
do
name=$line;
zmprov gdl $line|grep 'zimbraMailForwardingAddress:' > /tmp/tmp2.txt;
sed 's/zimbraMailForwardingAddress://g' /tmp/tmp2.txt > /tmp/tmp.txt;
dlists='';
for line1 in `cat /tmp/tmp.txt`;
do
dlists=$line1','$dlists;
done
echo $dlists;
echo $name':'$dlists >> $file;
sed -i '/^$/d' $file;
echo "">/tmp/tmp2.txt;
echo "">/tmp/tmp.txt;
done

Tuesday, March 2, 2010

getAccounts from Zimbra

Script to get account details from your zimbra mail server along with aliases. In our scenario, we did this for creating accounts in new server based on the information from the old server. The ouput file will be in the format below.
-------------------------------------
Email address:alias1,alias1
Email address2:alias1

-------------------------------------

Remarks: In this script, it will take only accounts in the active and locked state.

#!/bin/bash
#Declare name of output file in the variable below:
file=accountlist;
echo "" > $file;

for line in `zmprov gaa`;
do
status=`zmprov ga $line|grep 'zimbraAccountStatus:'|cut -d : -f 2`;
if [ $status == "active" ]||[ $status == "locked" ];
then
name=$line;
aliases='';
zmprov ga $name|grep 'zimbraMailAlias' > tmp3.txt;
for line1 in `sed 's/zimbraMailAlias://g' tmp3.txt`;
do
aliases=$line1','$aliases;
done
echo $name:$aliases >> $file;
sed -i '/^$/d' $file;
echo "" > tmp3.txt;
fi
done

Backing up in Scalix

Backing up a user folder:

Setup a cron to execute the command below at every night.
sxmboxexp -u "username" -a /path_to_file.mbox
Using crontab:
crontab -e
0 0 * * * sxmboxexp -u "username" -a /path_to_file.mbox
#The above command wil run at every night 12 AM.

To restore the mailbox using the back up,use the command below.

sxmboximp -u "John Doe" -a "/path_to_file.mbox" -s --listlevel folder

----------------------------------------------------------------------------------------------
For automatc back up of entire scalix directory.Refer the link below.

http://www.scalix.com/wiki/index.php?title=HowTos/AutoBackupScript