11#! /bin/bash
22#
3- # Backupscript for rdiff-backup with mysqlhotcopy and mysqldump
3+ # Backupscript for rdiff-backup with mysqldump
44# Author: Edvin Dunaway - edvin@eddinn.net
55#
66
@@ -22,10 +22,6 @@ export FILE_LIST="/path/to/backup-include-list"
2222export MYSQL_DIR=' /var/lib/mysql'
2323export MYSQL_BACKUP_DIR=" $BACKUP_DEST_PATH /mysql"
2424
25- # What to output of the mysql hotcopy.
26- # 0: Only errors, 1: "Pretty" output, 2: Everything
27- OUTPUT_LEVEL=1
28-
2925# Set rdiff-backup cleanup setting (removes all older then n days)
3026# The time interval is an integer followed by the character s, m, h, D, W, M, or Y,
3127# indicating seconds, minutes, hours, days, weeks, months, or years respectively, or a number of these concatenated.
@@ -63,39 +59,30 @@ for DIR in $_DBS; do
6359 fi
6460done
6561
66- # Hotcopying and manually exporting all DBs (except test and performance_schema) to MYSQL_BACKUP_DIR
67- echo -e " \\ nStarting hotcopying DBs and then we'll also do a manual export of the DBs into .sql files:"
62+ # Exporting all DBs (except test and performance_schema) to MYSQL_BACKUP_DIR
63+ echo -e " \\ nStarting export of DBs into .sql files:"
6864for DB in $_DBS ; do
69- if [ $OUTPUT_LEVEL -eq 1 ]; then echo -n " Hotcopying and exporting of DB $DB " ; fi
70- if [ $OUTPUT_LEVEL -le 1 ]; then QUIET=' -q' ; fi
71-
72- _DBEXPORT=$( mysqlhotcopy --allowold $QUIET " $DB " " $MYSQL_BACKUP_DIR " /" $DB " && mysqldump " $DB " > " $MYSQL_BACKUP_DIR " /" $DB " /" $DB " .sql 2>&1 )
65+ echo -n " Exporting DB $DB "
66+
67+ _DBEXPORT=$( mysqldump " $DB " > " $MYSQL_BACKUP_DIR " /" $DB " /" $DB " .sql 2>&1 )
7368 _EXIT=$?
7469 _FAILED=0
7570
7671 # Validate the exit code
7772 if [ $_EXIT -eq 0 ]; then
78- if [ $OUTPUT_LEVEL -eq 1 ]; then
79- echo -e " finished!"
80- elif [ $OUTPUT_LEVEL -eq 2 ]; then
81- echo -e " $_DBEXPORT "
82- fi
73+ echo -e " finished!"
8374 else
8475 _FAILED=$(( _FAILED + 1 ))
85- if [ $OUTPUT_LEVEL -eq 1 ]; then
86- echo -e " failed!"
87- echo -e " $_DBEXPORT " 1>&2
88- else
89- echo -e " $_DBEXPORT " 1>&2
90- fi
76+ echo -e " failed!"
77+ echo -e " $_DBEXPORT " 1>&2
9178 fi
9279done
9380
9481# Show results
9582if [ " $_FAILED " -eq 0 ]; then
96- if [ " $OUTPUT_LEVEL " -ge 1 ] ; then echo -e " \\ nMySQL DB export " ; fi
83+ echo -e " \\ nMySQL DB exported "
9784else
98- echo -e " \\ nFailed to hotcopy and export $_FAILED DBs!"
85+ echo -e " \\ nFailed to export $_FAILED DBs!"
9986fi
10087
10188echo -e " \\ nMySQL backup finished; Now running rdiff-backup on system data:"
0 commit comments