Quote:
|
Originally Posted by ChadScott Please note that this method only gives you a crash-consistent backup since the LVM snapshot freezes time. While ext3 will be in a consistent state, there's no guarantee that ZCS will have written a complete message to disk, updated metadata in the database, etc.
A better way of doing this would be to stop the zimbra services, perform the snapshot, restart the zimbra services, and then do a backup from the snapshot.
This will give you the most consistent data to restore and requires a minimum of downtime. |
Good point, ChadScott. Thanks for the feedback. The updated script is below.
DISCLAIMERS:
-This script has the potential of doing great damage--DO NOT TEST IT ON A PRODUCTION SYSTEM!
-This script does no error-checking whatsoever.
-I give no guarantees that this script will work for you and cannot be held liable for any damages that may occur.
-Use at your own risk!
-If your Zimbra server breaks, you get to keep both pieces.
-This script has NOT been tested in a production environment.
-This script has not had much testing at all.
-I have not yet verified that I can perform a successful restore from the backups that are produced by this script.
-The restore script is left as an exercise to the reader.
-This new script is no longer a hot-backup; however, as ChadScott points out, the total Zimbra downtime should be minimal.
ASSUMPTIONS:
-Fedora Core 4
-/opt/zimbra/ is on its own logical volume.
-The volume group that contains the logical volume for /opt/zimbra has free space that can be used to create a new logical volume for the snapshot.
-The script creates a full backup called zimbra.backup.tar.gz in a directory that is named with the date and time that the script was started at.
Code:
#!/bin/bash
time=`date +%Y-%m-%d_%H-%M-%S`
#########################################
# Modify the following variables according to your installation
#########################################
# backup_dir - directory to backup to
backup_dir=/media/usbdisk/zimbra/$time
# zimbra_vol - the Logical Volume that contains /opt/zimbra
zimbra_vol=LogVol02
# vol_group - the Volume Group that contains $zimbra_vol
vol_group=VolGroup00
#########################################
# Do not change anything beyond this point
#########################################
# Output date
echo Backup started at:
date
# Stop the Zimbra services
service zimbra stop
# Create a logical volume called ZimbraBackup
lvcreate -L1000M -s -n ZimbraBackup /dev/$vol_group/$zimbra_vol
# Create a mountpoint to mount the logical volume to
mkdir -p /mnt/ZimbraBackup
# Mount the logical volume to the mountpoint
mount /dev/$vol_group/ZimbraBackup /mnt/ZimbraBackup/
# Start the Zimbra services
service zimbra start
# For testing only
#echo Press Enter to continue . . .
#read input
# Create the current backup
mkdir -p $backup_dir
tar zcvf $backup_dir/zimbra.backup.tar.gz /mnt/ZimbraBackup/zimbra/ > /dev/null
# Unmount /mnt/ZimbraBackup and remove the logical volume
umount /mnt/ZimbraBackup/
echo y | lvremove /dev/$vol_group/ZimbraBackup
# Output date
echo Backup ended at:
date