Hello,
I would like to get a peer review of my backup script. Am I doing ok? Any recommendations?
We are backing up on the weekends, and I’m not concerned about a database outage at the time of backups. They take less than 5 minutes at this time so performance is quite acceptable.
Without further ado, here is the meaty part:
suffix=“POOH”
BACKUP_DIR=/home/mysql.backup
LOG_DIR=/var/log/mysql.backup
BACKUP_NAME=“full-$suffix”
FULL_BACKUP_DIR=“$BACKUP_DIR/$BACKUP_NAME”
echo “flush tables with read lock; set global read_only = ON;” | mysql --defaults-file=/var/lib/mysql/defaults.cnf
innobackupex --defaults-file $TMPFILE --no-timestamp $FULL_BACKUP_DIR > $LOG_DIR/$suffix 2>&1
innobackupex --defaults-file $TMPFILE --apply-log --no-timestamp $FULL_BACKUP_DIR >> $LOG_DIR/$suffix 2>&1
pt-table-checksum --defaults-file=/var/lib/mysql/defaults.cnf --chunk-size=1000000 --chunk-size-limit=0 --recursion-method none >/dev/null
echo “set global read_only = OFF; unlock tables;” | mysql --defaults-file=/var/lib/mysql/defaults.cnf
cd $FULL_BACKUP_DIR
mkdir external_files
Columns: db tbl this_crc this_cnt
echo “use percona; select db,tbl,this_crc,this_cnt from checksums;” | mysql --defaults-file=/var/lib/mysql/defaults.cnf > external_files/checksums.$suffix