Created
December 7, 2018 15:06
-
-
Save javierwilson/0cc88ba834f9c71d8a2fa586ee6c5e7d to your computer and use it in GitHub Desktop.
Backing up Cyrus mail server database
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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