Automatic Zimbra Backup


2008-03-10 Digg! icurtain Delcious icurtain Technorati icurtain


If you are backing up Zimbra to a remote NFS file system then you should probably mount it in the fstab r the init.d - bear in mind that if the remote box cannot be found on boot or shutdown the machine will hang for ages before it times out.

#mounts remote file system #init.d
mount remoteBox:/email/backup /mnt/emailbackup/
#fstab
remoteBox:/email/backup /mnt/emailbackup/ nfs rw,intr,bg 0 0

Zimbra's own script
#!/bin/bash
export time=`date +%Y-%m-%d_%H-%M-%S`
export backup_dir=/var/spool/zimbra/backup
export backup_file=$backup_dir/zimbra$time.tar.gz
export zimbra_dir=/opt/zimbra
mkdir -p $backup_dir
su zimbra --command="/opt/zimbra/bin/zmcontrol stop"
tar -czvf $backup_file $zimbra_dir
su zimbra --command="/opt/zimbra/bin/zmcontrol start"

Zimbra Backup Script

Put this in /etc/cron.daily

#!/bin/sh
#deletes all files from remot drive older than 7 days
find /mnt/emailbackup/ -maxdepth 1 -ctime +7 -daystart -exec rm "{}" \;

#run back up
/opt/zimbra/bin/zmfullbackup > /var/spool/zimbra/backup/backup.log

#move back up to remote drive
mv /var/spool/zimbra/backup/* /mnt/emailbackup