Backup webmail database

This commit is contained in:
Bob Mottram 2014-08-04 20:16:16 +01:00
parent b04b2a9010
commit c0d51f2544
1 changed files with 28 additions and 2 deletions

View File

@ -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