Rsync Kerio mailserver Store folder

This is the script I use on my Mac Mini Server to remotely backup the store directory on another server using rsync.


#!/bin/sh

if [ `id -u` != "0" ]; then
echo "Sorry, you are not root."
exit 1
fi

username=root
ip=192.168.0.7
dest=/opt/kerio/mailserver/store
folder=/usr/local/kerio/mailserver/store/

if [ $1 = "dry" ]; then
echo "Dry run activated. Simulating copy.";
dry=-n
fi;

if [ $1 = "log" ]; then
echo "Logging activated, directing output to /usr/local/kerio/log";
echo `date` >>/usr/local/kerio/log;
echo " " >>/usr/local/kerio/log;
options='-rumzh -v'
else
options='-rumzh -v --progress'
fi;

echo Options actived: $options $dry
echo ""
rsync $options $dry --delete-after --exclude=Outbox --exclude=tmp --exclude=logs --exclude=queue $username@$ip:$folder/. $dest

And this is the line in crontab:

*/5 * * * * /usr/local/kerio/sync.sh log > /usr/local/kerio/log

Leave a Reply

Your email address will not be published. Required fields are marked *