1#--source include/innodb_page_size.inc 2 3# Export single table from backup 4# (xtrabackup with --prepare --export) 5 6CREATE TABLE t1(i INT) ENGINE INNODB; 7INSERT INTO t1 VALUES(1); 8CREATE TABLE t21(i INT) ENGINE INNODB; 9INSERT INTO t21 VALUES(1); 10 11CREATE TABLE t2(i int) ENGINE INNODB; 12 13echo # xtrabackup backup; 14 15let targetdir=$MYSQLTEST_VARDIR/tmp/backup; 16--disable_result_log 17exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup "--tables=test.*1" --target-dir=$targetdir; 18--enable_result_log 19list_files $targetdir/test *.ibd; 20 21# Inject a junk .ibd file into backup dir to 22# see if prepare does not choke on it. 23write_file $targetdir/test/junk.ibd; 24EOF 25write_file $targetdir/test/junk.frm; 26EOF 27 28let server_cnf=$targetdir/server.cnf; 29copy_file $MYSQLTEST_VARDIR/my.cnf $server_cnf; 30 31# Emulate server config file turnes on binary logs 32perl; 33my $binlog_path="$ENV{'targetdir'}/mysqld-bin"; 34my $config_path=$ENV{'server_cnf'}; 35open(my $fd, '>>', "$config_path"); 36print $fd "\n[mysqld]\n"; 37print $fd "log-bin=$binlog_path\n"; 38close $fd; 39EOF 40 41echo # xtrabackup prepare; 42--disable_result_log 43exec $XTRABACKUP --defaults-file=$server_cnf --defaults-group-suffix=.1 --prepare --export --target-dir=$targetdir; 44--enable_result_log 45 46list_files $targetdir/test *.cfg; 47# There must not be binary logs created on --prepare step 48list_files $targetdir/ mysqld-bin.*; 49 50let $MYSQLD_DATADIR= `select @@datadir`; 51ALTER TABLE t1 DISCARD TABLESPACE; 52copy_file $targetdir/test/t1.ibd $MYSQLD_DATADIR/test/t1.ibd; 53copy_file $targetdir/test/t1.cfg $MYSQLD_DATADIR/test/t1.cfg; 54ALTER TABLE t1 IMPORT TABLESPACE; 55 56SELECT * FROM t1; 57DROP TABLE t1; 58DROP TABLE t2; 59DROP TABLE t21; 60rmdir $targetdir; 61