
Originally Posted by
msheean
The problem is that with our ~250GB installation it can take a loooong time to do the rsync. Our /opt/zimbra/backup folder has millions of files and the store folder has plenty of small message files that take well over a day to rsync. We can't be without mail for that long.
I know I could rsync the /opt/zimbra/backup folder separately to save some time but still it takes hours to rsync the rest. Has anyone else run into this problem?
As I do remote backups over the Internet, here is how I get around it. I shut down the server and do a mass hardlink of all the files to a /tmp path, I then delete the Zimbra's temporary files (which aren't needed in backup obviously) in the /tmp copy and delete the pid files in the /tmp copy. Deleting the pid files is essential, because daemons like postfix will refuse to start up if their pid file is hard linked. I then immediately after start zimbra up again and do the rsync on the /tmp files.
As hardlinked files automatically delink when either side is modified, leaving the unmodified copy intact, this gets around the known issue. Since the majority of files won't get modified substantially, you shouldn't expect a major increase in space used on the drive.
Here is a simplified script of what I use:
Code:
# Stop services
/etc/init.d/zimbra stop
# A small sleep is used in case a core is not being very responsive
sleep 2s
# Make sure all Zimbra owned processes are dead.
pkill -9 -u zimbra
# A small sleep is used in case a core is not being very responsive
sleep 2s
# Make sure there is nothing in the temporary path.
rm -rf /tmp/sysbackup
# Create temporary path
mkdir /tmp/sysbackup
# Hardlink Zimra installation
cp -al /opt/zimbra /tmp/sysbackup/
# Delete pid files
rm -f /tmp/sysbackup/opt/zimbra/data/postfix/master.lock /tmp/sysbackup/opt/zimbra/openldap-*/var/run/slapd.pid /tmp/sysbackup/opt/zimbra/cyrus-sasl-*/state/saslauthd.pid /tmp/sysbackup/opt/zimbra/db/mysql.pid /tmp/sysbackup/opt/zimbra/log/zmmailboxd_java.pid /tmp/sysbackup/opt/zimbra/log/memcached.pid /tmp/sysbackup/opt/zimbra/log/*.pid /tmp/sysbackup/opt/zimbra/zmstat/pid/* /tmp/sysbackup/opt/zimbra/data/postfix/spool/pid/*
# Delete temporary files
rm -rf /tmp/sysbackup/opt/zimbra/tmp /tmp/sysbackup/opt/zimbra/data/tmp
# Start zimbra in the background
/etc/init.d/zimbra start &
# rsync to remote server
rsync --delete --partial --stats -ihHavv -e "ssh -C -o CompressionLevel=9 -o ConnectionAttempts=15 -o ConnectTimeout=10 -o TCPKeepAlive=yes -o ServerAliveInterval=300" /tmp/sysbackup/ login@hostname:/path/to/backup/folder
# Delete temporary folder
rm -rf /tmp/sysbackup
This keeps the server down time to a minimum and shouldn't take substantially more space.