From c0d51f25449783851c49b8c71c0ffed97e1fbe75 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 4 Aug 2014 20:16:16 +0100 Subject: [PATCH] Backup webmail database --- beaglebone.txt | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/beaglebone.txt b/beaglebone.txt index a29a7951..84473258 100644 --- a/beaglebone.txt +++ b/beaglebone.txt @@ -4252,7 +4252,7 @@ if [ "$FILESIZE" -eq "0" ]; then cp $DAILYFILE $TEMPFILE # try to restore yesterday's database - mysql -D friendica -o < $DAILYFILE + mysql -u root --password=$MYSQL_PASSWORD friendica -o < $DAILYFILE # Send a warning email echo "Unable to create a backup of the Friendica database. Attempted to restore from yesterday's backup." | mail -s "Friendica backup" $EMAIL @@ -4269,6 +4269,32 @@ else fi +# Backup the Roundcube database +DAILYFILE=/var/backups/roundcubemail_daily.sql +mysqldump --password=$MYSQL_PASSWORD roundcubemail > $TEMPFILE +FILESIZE=$(stat -c%s $TEMPFILE) +if [ "$FILESIZE" -eq "0" ]; then + if [ -f $DAILYFILE ]; then + cp $DAILYFILE $TEMPFILE + + # try to restore yesterday's database + mysql -u root --password=$MYSQL_PASSWORD roundcubemail -o < $DAILYFILE + + # Send a warning email + echo "Unable to create a backup of the Roundcube database. Attempted to restore from yesterday's backup" | mail -s "Roundcube backup" $EMAIL + else + # Send a warning email + echo "Unable to create a backup of the Roundcube database." | mail -s "Roundcube backup" $EMAIL + fi +else + chmod 600 $TEMPFILE + mv $TEMPFILE $DAILYFILE + + # Make the backup readable only by root + chmod 600 $DAILYFILE +fi + + # Backup the Red Matrix database DAILYFILE=/var/backups/redmatrix_daily.sql #mysqldump --password=$MYSQL_PASSWORD redmatrix > $TEMPFILE @@ -4278,7 +4304,7 @@ DAILYFILE=/var/backups/redmatrix_daily.sql # cp $DAILYFILE $TEMPFILE # # try to restore yesterday's database -# mysql -D redmatrix -o < $DAILYFILE +# mysql -u root --password=$MYSQL_PASSWORD redmatrix -o < $DAILYFILE # # Send a warning email # echo "Unable to create a backup of the Red Matrix database. Attempted to restore from yesterday's backup" | mail -s "Red Matrix backup" $EMAIL