zimbraBackupAllAccounts.sh

#!/bin/bash

# Crontab

# 30 19 * * * sh /empresa/zimbraBackupAllAccounts.sh

mount 192.168.1.2:/backup/zimbra /mnt/backup/

PATH=$PATH:$HOME/bin:/opt/zimbra/bin

export PATH

ZHOME=/opt/zimbra

#ZBACKUP=$ZHOME/backup/mailbox

ZBACKUP=/mnt/backup

#ZCONFD=$ZHOME/conf

DATE=`date +"%a"`

ZDUMPDIR=$ZBACKUP/$DATE

ZMBOX=/opt/zimbra/bin/zmmailbox

if [ ! -d $ZDUMPDIR ]; then

mkdir -p $ZDUMPDIR

fi

echo " Running zmprov ... "

for mbox in `zmprov -l gaa`

do

echo " Generating files from backup $mbox ..."

$ZMBOX -z -m $mbox getRestURL "//?fmt=tgz" > $ZDUMPDIR/$mbox.tgz

done

# Apagando arquivos antigos (mais de 1 dias).

find /mnt/backup/ -mtime +1 -exec rm -rf {} \;

# Desmontando particao

umount /mnt/backup