You are here

Zimbra VM and LVM re-organization

My default Zimbra VM install uses LVM within its own virtual machine. This makes it harder to get at the data from outside the VM, and so complicates backup. The following steps need to be taken

Backup original Zimbra VM

#stop Zimbra to ensure consistent file (have to be logged on to Zimbra machine for start & stop)
zimbra# /etc/init.d/zimbra stop
zimbra# ps aux | grep zimbra #(kill -9 pid# of any remaining processes)
#create a snapshot of the LV drive
/usr/sbin/lvcreate -L5G -s -n vm_zimbra_snap /dev/VolGroup00/vm_zimbra
#re-start Zimbra
zimbra# /etc/init.d/zimbra start
#turn the snapshop into a file image
nice dd if=/dev/VolGroup00/vm_zimbra_snap | bzip2 --best >/backups/vm_zimbra_$(date +"%Y%m%d")
#remove the snapshot
/usr/sbin/lvremove /dev/VolGroup00/vm_zimbra_snap

Make separate LVM volume for Zimbra tree within mail VM

#create zimbra data volume and format it as ext3
/usr/sbin/lvcreate -L50G -n opt_zimbra VolGroup00
/sbin/mkfs.ext3 /dev/VolGroup00/opt_zimbra
#modify the line in the zimbra xen configuration file to make this accessible to the xen VM

disk = [ ,'phy:/dev/VolGroup00/opt_zimbra,xvdb,w', ]
#log into Zimbra VM and do: /etc/init.d/zimbra stop
#restart Zimbra VM
#check Zimbra has restarted, and then do a first pass at the backup
cd /opt
mkdir zimbra-new
mount /dev/xvdb zimbra-new
rsync -a zimbra/ zimbra-new
#stop Zimbra for the final pass
/etc/init.d/zimbra stop
rsync -av --delete zimbra/ zimbra-new
mv zimbra zimbra-old
umount /dev/xvdb
mkdir zimbra
mount /dev/xvdb zimbra
/etc/init.d/zimbra start
#check it all works
#edit /etc/fstab to remount zimbra volume:
/dev/xvdb /opt/zimbra ext3 defaults 0 0

Increase size of LVM volume for Zimbra

#first stop Zimbra in client machine, e.g. log in as zimbra and: zmcontrol 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
mkdir /backups/snap
mount /dev/VolGroup00/zimbra_opt_snap /backups/snap -t ext3
rsync -aH --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.bz2 /backups/zimbra/

#Expand: see
lvextend -L+10G /dev/VolGroup00/opt_zimbra

#stop Zimbra
umount /opt/zimbra
resize2fs /dev/xvdb
mount /dev/xvdb /opt/zimbra
#restart Zimbra