Zimbra backup using LVM and rsync


#stop Zimbra to ensure consistent file (have to be logged on to Zimbra machine for start & stop)
zimbra# /etc/init.d/zimbra stop
#create a snapshot of the LV drive from the host machine
/usr/sbin/lvcreate -L5G -s -n zimbra_opt_snap /dev/VolGroup00/opt_zimbra
#re-start Zimbra
zimbra# /etc/init.d/zimbra start
# AS ROOT IN HOST MACHINE
mkdir /backups/snap
mount /dev/VolGroup00/zimbra_opt_snap /backups/snap -t ext3
rsync -av --delete /backups/snap/ /backups/zimbra
umount /backups/snap
rmdir /backups/snap

#remove the snapshot
/usr/sbin/lvremove -f /dev/VolGroup00/zimbra_opt_snap
#files can be compressed to archive using:
nice tar cjvf /backups/zim$(date +"%Y%m%d").tar.bz /backups/zimbra/
#or for whole image:
nice dd if=/dev/VolGroup00/zimbra_opt_snap | bzip2 --best >/mnt/opt_zimbra_$(date +"%Y%m%d").dd.bz