Steps for Successful Backup and Recovery Using MySQL Enterprise Backup
Steps for Successful Backup and Recovery Using MySQL Enterprise Backup
# mkdir /backup
2. Create a MySQLBackup group in my.cnf file and also add innodb info in mysqld section.
[mysqld]
innodb_log_files_in_group=2
innodb_log_file_size=512M
innodb_data_file_path=ibdata1:76M:autoextend
#make ensure that the file size should exactly match with your current ibdata1 file.
[mysqlbackup]
backup-dir=/backup
socket=/var/lib/mysql/mysql.sock
5 If it executed success fully then perform next step else troubleshoot the problem.
a) ibadat1
b) ib_logfile0
c) ib_logfile1
# also ensure that the owner of every file and folder in /var/lib/mysql is mysql user.
Incremental backup
Start lsn is the “ end lsn “ values copied from you last backup dir/meta directory’s backup_variables.txt
file
Command is :
Merge all incremental backup directories start from the oldest.in our case /Friday2 is the oldest
incremental backup directory.
After that use the same method of recovery which you have used for full backup recovery method.
./mysqlbackup -p copy-back
#!/bin/bash -x
#Tue Jul 2 15:32:21 CEST 2013
#Made by Edward Z.
set -e #stops execution if a variable is not set
set -u #stop execution if something goes wrong
usage() {
echo "usage: $(basename $0) [option]"
echo "option=full: do a full backup of vinnie /var/lib/mysql using
innobackupex, aprox time 6 hours."
echo "option=incremental: do a incremental backup"
echo "option=restore: this will restore the latest backup to vinnie,
BE CAREFUL!"
echo "option=help: show this help"
}
full_backup() {
date
if [ ! -d $BACKUP_DIR ]
then
echo "ERROR: the folder $BACKUP_DIR does not exists"
exit 1
fi
echo "doing full backup..."
echo "cleaning the backup folder..."
rm -rf $BACKUP_DIR/*
echo "cleaning done!"
innobackupex $ARGS $BACKUP_DIR/FULL
date
echo "backup done!, now uncompressing the files..."
for bf in `find $BACKUP_DIR/FULL -iname "*\.qp"`; do qpress -d $bf $
(dirname $bf) ;echo "processing" $bf; rm $bf; done
date
echo "uncompressing done!, preparing the backup for restore..."
innobackupex --apply-log --redo-only $BACKUP_DIR/FULL
date
echo "preparation done!"
}
incremental_backup()
{
if [ ! -d $BACKUP_DIR/FULL ]
then
echo "ERROR: no full backup has been done before. aborting"
exit -1
fi
restore()
{
echo "WARNING: are you sure this is what you want to do? (Enter 1 or
2)"
select yn in "Yes" "No"; do
case $yn in
Yes ) break;;
No ) echo "aborting... that was close."; exit;;
esac
done
if [ -d $BACKUP_DIR/inc$P ]
then
#the last incremental has to be applied without the redo-only
flag
echo "processing last incremental $P"
innobackupex --apply-log $BACKUP_DIR/FULL --incremental-
dir=$BACKUP_DIR/inc$P
fi
#######################################
#######################################
#######################################
BACKUP_DIR=/tmp/backup
DATA_DIR=/var/lib/mysql
USER_ARGS=" --user=root --password=password"
if [ $# -eq 0 ]
then
usage
exit 1
fi
case $1 in
"full")
full_backup
;;
"incremental")
incremental_backup
;;
"restore")
restore
;;
"help")
usage
break
;;
*) echo "invalid option";;
esac