A Linux friend of mine (not a Zimbra user yet!) corrected my tar command. It had been working fine at the command prompt but was not behaving when run from crontab, apparently because it wasn't properly going to the right source directory.
So here is the revised script, tested and working on Ubuntu 6.06:
Code:
#!/bin/bash
# Zimbra Backup Script
# Requires ncftp to run
# This script is intended to run from the crontab as root
# Free to use and free of any warranty! Daniel W. Martin, 9 Sept 2007
# Live sync before stopping Zimbra to minimize sync time with the services down
# Comment out the following line if you want to try single cold-sync only
rsync -avHK /opt/zimbra/ /backup/zimbra
# Stop Zimbra Services
sudo -u zimbra /opt/zimbra/bin/zmcontrol stop
sleep 15
# Sync to backup directory
rsync -avHK /opt/zimbra/ /backup/zimbra
# Restart Zimbra Services
sudo -u zimbra /opt/zimbra/bin/zmcontrol start
# Create archive of backed-up directory for offsite transfer
# cd /backup/zimbra
tar -zcvf /tmp/mail.backup.gz -C /backup/zimbra .
# Transfer file to backup server
ncftpput -u <username> -p <password> <ftpserver> /<desired dest. directory> /tmp/mail.backup.gz
This revision has also been corrected on the wiki