Skip to content

Instantly share code, notes, and snippets.

@javierwilson
Created December 7, 2018 15:06
Show Gist options
  • Save javierwilson/0cc88ba834f9c71d8a2fa586ee6c5e7d to your computer and use it in GitHub Desktop.
Save javierwilson/0cc88ba834f9c71d8a2fa586ee6c5e7d to your computer and use it in GitHub Desktop.
Backing up Cyrus mail server database
#!/bin/bash
DEST=/backup1/example/mail/spool/
TEST=/backup1/BACKUP.txt
if [ ! -f $TEST ]; then
echo "Backup disk not mounted!"
exit
fi
echo "Rsyncing..."
rsync --bwlimit=5000 --delete -a -v example.com:/var/spool/imap $DEST
result=$?
if [ $result -eq 0 ]; then
echo "Rotating..."
rm -fr $DEST/imap.4
mv $DEST/imap.3 $DEST/imap.4
mv $DEST/imap.2 $DEST/imap.3
mv $DEST/imap.1 $DEST/imap.2
cp -al $DEST/imap $DEST/imap.1
else
echo "Backup FAILED! Not rotating."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment