瀏覽代碼

Backup webmail database

Bob Mottram 11 年之前
父節點
當前提交
c0d51f2544
共有 1 個檔案被更改,包括 28 行新增2 行删除
  1. 28
    2
      beaglebone.txt

+ 28
- 2
beaglebone.txt 查看文件

4252
         cp $DAILYFILE $TEMPFILE
4252
         cp $DAILYFILE $TEMPFILE
4253
 
4253
 
4254
         # try to restore yesterday's database
4254
         # try to restore yesterday's database
4255
-        mysql -D friendica -o < $DAILYFILE
4255
+        mysql -u root --password=$MYSQL_PASSWORD friendica -o < $DAILYFILE
4256
 
4256
 
4257
         # Send a warning email
4257
         # Send a warning email
4258
         echo "Unable to create a backup of the Friendica database. Attempted to restore from yesterday's backup." | mail -s "Friendica backup" $EMAIL
4258
         echo "Unable to create a backup of the Friendica database. Attempted to restore from yesterday's backup." | mail -s "Friendica backup" $EMAIL
4269
 fi
4269
 fi
4270
 
4270
 
4271
 
4271
 
4272
+# Backup the Roundcube database
4273
+DAILYFILE=/var/backups/roundcubemail_daily.sql
4274
+mysqldump --password=$MYSQL_PASSWORD roundcubemail > $TEMPFILE
4275
+FILESIZE=$(stat -c%s $TEMPFILE)
4276
+if [ "$FILESIZE" -eq "0" ]; then
4277
+    if [ -f $DAILYFILE ]; then
4278
+        cp $DAILYFILE $TEMPFILE
4279
+
4280
+        # try to restore yesterday's database
4281
+        mysql -u root --password=$MYSQL_PASSWORD roundcubemail -o < $DAILYFILE
4282
+
4283
+        # Send a warning email
4284
+        echo "Unable to create a backup of the Roundcube database. Attempted to restore from yesterday's backup" | mail -s "Roundcube backup" $EMAIL
4285
+	else
4286
+        # Send a warning email
4287
+        echo "Unable to create a backup of the Roundcube database." | mail -s "Roundcube backup" $EMAIL
4288
+    fi
4289
+else
4290
+    chmod 600 $TEMPFILE
4291
+    mv $TEMPFILE $DAILYFILE
4292
+
4293
+    # Make the backup readable only by root
4294
+    chmod 600 $DAILYFILE
4295
+fi
4296
+
4297
+
4272
 # Backup the Red Matrix database
4298
 # Backup the Red Matrix database
4273
 DAILYFILE=/var/backups/redmatrix_daily.sql
4299
 DAILYFILE=/var/backups/redmatrix_daily.sql
4274
 #mysqldump --password=$MYSQL_PASSWORD redmatrix > $TEMPFILE
4300
 #mysqldump --password=$MYSQL_PASSWORD redmatrix > $TEMPFILE
4278
 #        cp $DAILYFILE $TEMPFILE
4304
 #        cp $DAILYFILE $TEMPFILE
4279
 
4305
 
4280
 #        # try to restore yesterday's database
4306
 #        # try to restore yesterday's database
4281
-#        mysql -D redmatrix -o < $DAILYFILE
4307
+#        mysql -u root --password=$MYSQL_PASSWORD redmatrix -o < $DAILYFILE
4282
 
4308
 
4283
 #        # Send a warning email
4309
 #        # Send a warning email
4284
 #        echo "Unable to create a backup of the Red Matrix database. Attempted to restore from yesterday's backup" | mail -s "Red Matrix backup" $EMAIL
4310
 #        echo "Unable to create a backup of the Red Matrix database. Attempted to restore from yesterday's backup" | mail -s "Red Matrix backup" $EMAIL