Not the answer you need?
Register and ask your own question!

percona xrabackup not restore increment backup

Aleks305Aleks305 EntrantLegacy User Role Beginner
Hi!
We use percona-xtrabackup-2.3.8 on centos 6. We backup our mysql replica server using script :

#!/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

#we need the incremental number
if [ ! -f $BACKUP_DIR/last_incremental_number ]; then
NUMBER=1
else
NUMBER=$(($(cat $BACKUP_DIR/last_incremental_number) + 1))
fi
date
echo "doing incremental number $NUMBER"
if [ $NUMBER -eq 1 ]
then
innobackupex $ARGS --incremental $BACKUP_DIR/inc$NUMBER --incremental-basedir=$BACKUP_DIR/FULL
else
innobackupex $ARGS --incremental $BACKUP_DIR/inc$NUMBER --incremental-basedir=$BACKUP_DIR/inc$(($NUMBER - 1))
fi
date
echo $NUMBER > $BACKUP_DIR/last_incremental_number
echo "incremental $NUMBER done!, now uncompressing the files..."
for bf in `find $BACKUP_DIR/inc$NUMBER -iname "*\.qp"`; do qpress -d $bf $(dirname $bf) ;echo "processing" $bf; rm $bf; done
date
echo "uncompressing done!, the preparation will be made when the restore is needed"

}

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

echo "cross your fingers :)"
date
echo "doing restore..."
#innobackupex --apply-log --redo-only $BACKUP_DIR/FULL

#we append all the increments
P=1
while [ -d $BACKUP_DIR/inc$P ] && [ -d $BACKUP_DIR/inc$(($P+1)) ]
do
echo "processing incremental $P"
innobackupex --apply-log --redo-only $BACKUP_DIR/FULL --incremental-dir=$BACKUP_DIR/inc$P
P=$(($P+1))
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

#we prepare the full
innobackupex --apply-log $BACKUP_DIR/FULL

#finally we copy the folder
cp -r $DATA_DIR $DATA_DIR.back
rm -rf $DATA_DIR/*
innobackupex --copy-back $BACKUP_DIR/FULL

chown -R mysql:mysql $DATA_DIR

}

#######################################
#######################################
#######################################

BACKUP_DIR=/backup/jcat/jcat-mysql-incr
DATA_DIR=/var/lib/mysql
USER_ARGS=" --user=root --password="

ARGS="--rsync $USER_ARGS --no-timestamp --databases="jfsd" --compress --compress-threads=4"

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

/root/scripts/test-backup-mysql.sh full
and every 3 hours:

/root/scripts/test-backup-mysql.sh incremental

We try to restore backup with folloing commands:
innobackupex --apply-log --redo-only /backup/jmysql-incr/FULL
innobackupex --apply-log --redo-only /backup/mysql-incr/FULL --incremental-dir=/backup/jmysql-incr/inc1/
innobackupex --apply-log --redo-only /backup/mysql-incr/FULL --incremental-dir=/backup/mysql-incr/inc2
All work fine:
170424 12:35:10 completed OK!

And after that:
innobackupex --apply-log /backup/jcat/jcat-mysql-incr/FULL
InnoDB: The log sequence number in the ibdata files is higher than the log sequence number in the ib_logfiles! Are you sure you are using the right ib_logfiles to start up the database. Log sequence number in the ib_logfiles is 38413626823692, logsequence numbers stamped to ibdata file headers are between 38425159580938 and 38425159580938.
InnoDB: The log sequence numbers 38425159580938 and 38425159580938 in ibdata files do not match the log sequence number 38413626823692 in the ib_logfiles!

...............................


InnoDB: about forcing recovery.
09:42:51 UTC - xtrabackup got signal 6 ;
This could be because you hit a bug or data is corrupted.
This error can also be caused by malfunctioning hardware.
We will try our best to scrape up some info that will hopefully help
diagnose the problem, but since we have already crashed,
something is definitely wrong and this may fail.

Thread pointer: 0x0
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = 0 thread_stack 0x10000
xtrabackup(my_print_stacktrace+0x2e) [0x9300ae]
xtrabackup(handle_fatal_signal+0x273) [0x86b823]
/lib64/libpthread.so.0(+0xf7e0) [0x7fc8625ee7e0]
/lib64/libc.so.6(gsignal+0x35) [0x7fc8605bc625]
/lib64/libc.so.6(abort+0x175) [0x7fc8605bde05]
xtrabackup() [0x6d9158]
xtrabackup(mem_heap_create_block_func(mem_block_info_t*, unsigned long, unsigned long)+0x137) [0x6481a7]
xtrabackup(mem_heap_add_block(mem_block_info_t*, unsigned long)+0x49) [0x648389]
xtrabackup(mem_heap_dup(mem_block_info_t*, void const*, unsigned long)+0x5c) [0x64856c]
xtrabackup(trx_undo_get_undo_rec_low(unsigned long, mem_block_info_t*)+0xf0) [0x6884a0]
xtrabackup(trx_undo_prev_version_build(unsigned char const*, mtr_t*, unsigned char const*, dict_index_t*, unsigned long*, mem_block_info_t*, unsigned char**)+0x36a) [0x68ac3a]
xtrabackup(row_vers_build_for_consistent_read(unsigned char const*, mtr_t*, dict_index_t*, unsigned long**, read_view_t*, mem_block_info_t**, mem_block_info_t*, unsigned char**)+0x11d) [0x65413d]
xtrabackup() [0x942b8c]
xtrabackup(row_sel_step(que_thr_t*)+0x3b) [0x94322b]
xtrabackup(que_run_threads(que_thr_t*)+0x380) [0x6978e0]
xtrabackup(fts_eval_sql(trx_t*, que_fork_t*)+0x2d) [0x7077dd]
xtrabackup(fts_drop_orphaned_tables()+0x2c4) [0x6f4424]
xtrabackup(recv_recovery_rollback_active()+0x2f) [0x66e5ef]
xtrabackup(innobase_start_or_create_for_mysql()+0x1916) [0x703836]
xtrabackup() [0x593f27]
xtrabackup(main+0x8f5) [0x596865]
/lib64/libc.so.6(__libc_start_main+0xfd) [0x7fc8605a8d5d]
xtrabackup() [0x589379]

Please report a bug at https://bugs.launchpad.net/percona-xtrabackup

Please help!
Sign In or Register to comment.

MySQL, InnoDB, MariaDB and MongoDB are trademarks of their respective owners.
Copyright ©2005 - 2020 Percona LLC. All rights reserved.