Commit ca24f35b authored by Vladislav Vaintroub's avatar Vladislav Vaintroub Committed by Sergei Golubchik

MDEV-9566 MariaBackup test suite

parent 1991411f
--loose-skip-log-bin
\ No newline at end of file
CREATE TABLE t(i INT) ENGINE INNODB;
INSERT INTO t VALUES(1);
# xtrabackup backup
INSERT INTO t VALUES(2);
# xtrabackup prepare
# shutdown server
# remove datadir
# xtrabackup move back
# restart server
SELECT * FROM t;
i
1
DROP TABLE t;
CREATE TABLE t(i INT) ENGINE INNODB;
INSERT INTO t VALUES(1);
echo # xtrabackup backup;
let $targetdir=$MYSQLTEST_VARDIR/tmp/backup;
--disable_result_log
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir;
--enable_result_log
INSERT INTO t VALUES(2);
echo # xtrabackup prepare;
--disable_result_log
exec $XTRABACKUP --prepare --target-dir=$targetdir;
exec $XTRABACKUP --defaults-file=$targetdir/backup-my.cnf --stats --datadir=$targetdir;
-- source include/restart_and_restore.inc
--enable_result_log
SELECT * FROM t;
DROP TABLE t;
rmdir $targetdir;
if (`SELECT COUNT(*)=0 FROM INFORMATION_SCHEMA.PLUGINS WHERE PLUGIN_NAME = 'file_key_management' AND PLUGIN_STATUS='ACTIVE'`)
{
--skip Test requires file_key_management plugin
}
let $_server_id= `SELECT @@server_id`;
let $_datadir= `SELECT @@datadir`;
let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.$_server_id.expect;
exec echo "wait" > $_expect_file_name;
echo # shutdown server;
shutdown_server;
echo # remove datadir;
rmdir $_datadir;
echo # xtrabackup move back;
exec $XTRABACKUP --copy-back --datadir=$_datadir --target-dir=$targetdir --parallel=2;
echo # restart server;
exec echo "restart" > $_expect_file_name;
enable_reconnect;
source include/wait_until_connected_again.inc;
disable_reconnect;
call mtr.add_suppression("InnoDB: New log files created");
CREATE TABLE t(i INT) ENGINE INNODB;
INSERT INTO t VALUES(1);
# Create full backup , modify table, then create incremental/differential backup
INSERT INTO t VALUES(2);
SELECT * FROM t;
i
1
2
# Prepare full backup, apply incremental one
# Restore and check results
# shutdown server
# remove datadir
# xtrabackup move back
# restart server
SELECT * FROM t;
i
1
2
DROP TABLE t;
call mtr.add_suppression("InnoDB: New log files created");
let $basedir=$MYSQLTEST_VARDIR/tmp/backup;
let $incremental_dir=$MYSQLTEST_VARDIR/tmp/backup_inc1;
CREATE TABLE t(i INT) ENGINE INNODB;
INSERT INTO t VALUES(1);
echo # Create full backup , modify table, then create incremental/differential backup;
--disable_result_log
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$basedir;
--enable_result_log
INSERT INTO t VALUES(2);
SELECT * FROM t;
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$incremental_dir --incremental-basedir=$basedir;
--disable_result_log
echo # Prepare full backup, apply incremental one;
exec $XTRABACKUP --prepare --apply-log-only --target-dir=$basedir;
exec $XTRABACKUP --prepare --target-dir=$basedir --incremental-dir=$incremental_dir ;
echo # Restore and check results;
let $targetdir=$basedir;
-- source include/restart_and_restore.inc
--enable_result_log
SELECT * FROM t;
DROP TABLE t;
# Cleanup
rmdir $basedir;
rmdir $incremental_dir;
--innodb-tablespaces-encryption
--plugin-load-add=$DEBUG_KEY_MANAGEMENT_SO
--loose-debug_key_management_version=2
call mtr.add_suppression("InnoDB: New log files created");
CREATE TABLE t(i INT) ENGINE INNODB ENCRYPTED=YES;
INSERT INTO t VALUES(1);
# Create full backup , modify table, then create incremental/differential backup
INSERT INTO t VALUES(2);
SELECT * FROM t;
i
1
2
# Prepare full backup, apply incremental one
# Restore and check results
# shutdown server
# remove datadir
# xtrabackup move back
# restart server
SELECT * FROM t;
i
1
2
DROP TABLE t;
if (!$EXAMPLE_KEY_MANAGEMENT_SO)
{
--skip needs example_key_management plugin
}
call mtr.add_suppression("InnoDB: New log files created");
let $basedir=$MYSQLTEST_VARDIR/tmp/backup;
let $incremental_dir=$MYSQLTEST_VARDIR/tmp/backup_inc1;
CREATE TABLE t(i INT) ENGINE INNODB ENCRYPTED=YES;
INSERT INTO t VALUES(1);
echo # Create full backup , modify table, then create incremental/differential backup;
--disable_result_log
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$basedir;
--enable_result_log
INSERT INTO t VALUES(2);
SELECT * FROM t;
--disable_result_log
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$incremental_dir --incremental-basedir=$basedir;
echo # Prepare full backup, apply incremental one;
exec $XTRABACKUP --prepare --apply-log-only --target-dir=$basedir;
exec $XTRABACKUP --prepare --target-dir=$basedir --incremental-dir=$incremental_dir;
# stats also can support encryption, but needs plugin-load and plugin variables, they are stored in backup-my.cnf
# We need to prepare again to create log files though.
exec $XTRABACKUP --prepare --target-dir=$basedir;
exec $XTRABACKUP --defaults-file=$basedir/backup-my.cnf --stats --datadir=$basedir;
echo # Restore and check results;
let $targetdir=$basedir;
-- source include/restart_and_restore.inc
--enable_result_log
SELECT * FROM t;
DROP TABLE t;
# Cleanup
rmdir $basedir;
rmdir $incremental_dir;
CREATE TABLE t1(i INT) ENGINE INNODB;
INSERT INTO t1 VALUES(1);
CREATE TABLE t2(i int) ENGINE INNODB;
# xtrabackup backup
t1.ibd
# xtrabackup prepare
ALTER TABLE t1 DISCARD TABLESPACE;
ALTER TABLE t1 IMPORT TABLESPACE;
SELECT * FROM t1;
i
1
DROP TABLE t1;
DROP TABLE t2;
# Export single table from backup
# (xtrabackup with --prepare --export)
CREATE TABLE t1(i INT) ENGINE INNODB;
INSERT INTO t1 VALUES(1);
CREATE TABLE t2(i int) ENGINE INNODB;
echo # xtrabackup backup;
let $targetdir=$MYSQLTEST_VARDIR/tmp/backup;
--disable_result_log
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup "--tables=test.*1" --target-dir=$targetdir;
--enable_result_log
list_files $targetdir/test *.ibd;
echo # xtrabackup prepare;
--disable_result_log
exec $XTRABACKUP --prepare --export --target-dir=$targetdir;
--enable_result_log
ALTER TABLE t1 DISCARD TABLESPACE;
let $MYSQLD_DATADIR= `select @@datadir`;
copy_file $targetdir/test/t1.ibd $MYSQLD_DATADIR/test/t1.ibd;
copy_file $targetdir/test/t1.cfg $MYSQLD_DATADIR/test/t1.cfg;
ALTER TABLE t1 IMPORT TABLESPACE;
SELECT * FROM t1;
DROP TABLE t1;
DROP TABLE t2;
rmdir $targetdir;
# Check if ibd smaller than page size are skipped
# It is possible, due to race conditions that new file
# is created by server while xtrabackup is running
# The first page in this file does not yet exist.
# xtrabackup should skip such file.
let $_datadir= `SELECT @@datadir`;
write_file $_datadir/test/small.ibd;
EOF
echo #backup;
let $targetdir=$MYSQLTEST_VARDIR/tmp/backup;
--disable_result_log
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir;
--enable_result_log
remove_file $_datadir/test/small.ibd;
rmdir $targetdir;
--innodb --changed_page_bitmaps --innodb-file-format=Barracuda
\ No newline at end of file
package My::Suite::MariaBackup;
@ISA = qw(My::Suite);
use My::Find;
use File::Basename;
use strict;
return "Not run for embedded server" if $::opt_embedded_server;
my $mariabackup_exe=
::mtr_exe_maybe_exists(
"$::bindir/extra/mariabackup$::opt_vs_config/mariabackup",
"$::path_client_bindir/mariabackup");
return "No mariabackup" if !$mariabackup_exe;
$ENV{XTRABACKUP}= $mariabackup_exe;
$ENV{XBSTREAM}= ::mtr_exe_maybe_exists(
"$::bindir/extra/mariabackup/$::opt_vs_config/mbstream",
"$::path_client_bindir/mbstream");
my $tar_version = `tar --version 2>&1`;
$ENV{HAVE_TAR} = $! ? 0: 1;
my $mariabackup_help=`$mariabackup_exe --help 2>&1`;
$ENV{HAVE_XTRABACKUP_TAR_SUPPORT} = (index($mariabackup_help,"'tar'") == -1) ? 0 : 1;
$ENV{INNOBACKUPEX}= "$mariabackup_exe --innobackupex";
sub skip_combinations {
my %skip;
$skip{'include/have_file_key_management.inc'} = 'needs file_key_management plugin' unless $ENV{FILE_KEY_MANAGEMENT_SO};
%skip;
}
bless { };
CREATE TABLE t(i INT) ENGINE INNODB;
INSERT INTO t VALUES(1);
# xtrabackup backup
# xtrabackup prepare
# shutdown server
# remove datadir
# xtrabackup move back
# restart server
SELECT * FROM t;
i
1
DROP TABLE t;
if (`select $HAVE_TAR = 0`)
{
--skip No tar
}
if (`select $HAVE_XTRABACKUP_TAR_SUPPORT = 0`)
{
--skip Compiled without libarchive
}
CREATE TABLE t(i INT) ENGINE INNODB;
INSERT INTO t VALUES(1);
echo # xtrabackup backup;
let $targetdir=$MYSQLTEST_VARDIR/tmp/backup;
let $streamfile=$MYSQLTEST_VARDIR/tmp/backup.tar;
mkdir $targetdir;
exec $XTRABACKUP "--defaults-file=$MYSQLTEST_VARDIR/my.cnf" --backup --stream=tar > $streamfile 2>$targetdir/backup_stream.log;
--disable_result_log
exec tar -C $targetdir -x < $streamfile;
echo # xtrabackup prepare;
exec $XTRABACKUP --prepare --target-dir=$targetdir;
-- source include/restart_and_restore.inc
--enable_result_log
SELECT * FROM t;
DROP TABLE t;
rmdir $targetdir;
--plugin-load-add=$AWS_KEY_MANAGEMENT_SO
--loose-aws-key-management
--loose-aws-key-management-master-key-id=$AWS_KEY_MANAGEMENT_MASTER_KEY_ID
CREATE TABLE t(c VARCHAR(10)) ENGINE INNODB encrypted=yes;
INSERT INTO t VALUES('foobar1');
# xtrabackup backup
# shutdown server
# remove datadir
# xtrabackup move back
# restart server
SELECT * from t;
c
foobar1
DROP TABLE t;
if (`SELECT COUNT(*)=0 FROM INFORMATION_SCHEMA.PLUGINS WHERE PLUGIN_NAME = 'aws_key_management' AND PLUGIN_STATUS='ACTIVE'`)
{
--skip needs aws_key_management plugin plugin
}
if (`SELECT @@aws_key_management_master_key_id=''`)
{
--skip Test requires AWS_KEY_MANAGEMEMENT_MASTER_KEY_ID env. variable
}
CREATE TABLE t(c VARCHAR(10)) ENGINE INNODB encrypted=yes;
INSERT INTO t VALUES('foobar1');
echo # xtrabackup backup;
let $targetdir=$MYSQLTEST_VARDIR/tmp/backup;
--disable_result_log
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir;
exec $XTRABACKUP --prepare --target-dir=$targetdir;
-- source include/restart_and_restore.inc
--enable_result_log
SELECT * from t;
DROP TABLE t;
rmdir $targetdir;
--innodb-encryption-rotate-key-age=2
--innodb-encryption-threads=4
--innodb-tablespaces-encryption
--plugin-load-add=$FILE_KEY_MANAGEMENT_SO
--loose-file-key-management
--loose-file-key-management-filename=$MYSQL_TEST_DIR/std_data/logkey.txt
--innodb_strict_mode
--innodb_file_per_table
--innodb_file_format=Barracuda
CREATE TABLE t1(c1 INT, b VARCHAR(2400), index(b(100),c1)) ENGINE=INNODB ROW_FORMAT=compressed ENCRYPTED=YES;
CREATE PROCEDURE innodb_insert_proc (REPEAT_COUNT INT)
BEGIN
DECLARE CURRENT_NUM INT;
SET CURRENT_NUM = 0;
WHILE CURRENT_NUM < REPEAT_COUNT DO
INSERT INTO t1 VALUES(CURRENT_NUM, concat(uuid(), CURRENT_NUM, repeat('ab', floor(rand()*100) ), uuid()));
SET CURRENT_NUM = CURRENT_NUM + 1;
END WHILE;
END//
COMMIT;
SET AUTOCOMMIT=0;
CALL innodb_insert_proc(50000);
COMMIT;
# xtrabackup backup
drop table t1;
# shutdown server
# remove datadir
# xtrabackup move back
# restart server
select sum(c1) from t1;
sum(c1)
1249975000
DROP TABLE t1;
drop procedure innodb_insert_proc;
source include/have_file_key_management.inc;
CREATE TABLE t1(c1 INT, b VARCHAR(2400), index(b(100),c1)) ENGINE=INNODB ROW_FORMAT=compressed ENCRYPTED=YES;
DELIMITER //;
CREATE PROCEDURE innodb_insert_proc (REPEAT_COUNT INT)
BEGIN
DECLARE CURRENT_NUM INT;
SET CURRENT_NUM = 0;
WHILE CURRENT_NUM < REPEAT_COUNT DO
INSERT INTO t1 VALUES(CURRENT_NUM, concat(uuid(), CURRENT_NUM, repeat('ab', floor(rand()*100) ), uuid()));
SET CURRENT_NUM = CURRENT_NUM + 1;
END WHILE;
END//
DELIMITER ;//
COMMIT;
SET AUTOCOMMIT=0;
CALL innodb_insert_proc(50000);
COMMIT;
echo # xtrabackup backup;
--disable_result_log
let $targetdir=$MYSQLTEST_VARDIR/tmp/backup;
exec $INNOBACKUPEX --defaults-file=$MYSQLTEST_VARDIR/my.cnf --no-timestamp $targetdir;
drop table t1;
exec $INNOBACKUPEX --apply-log $targetdir;
-- source include/restart_and_restore.inc
--enable_result_log
select sum(c1) from t1;
DROP TABLE t1;
drop procedure innodb_insert_proc;
rmdir $targetdir;
--innodb-encrypt-log=ON
--plugin-load-add=$FILE_KEY_MANAGEMENT_SO
--loose-file-key-management
--loose-file-key-management-filekey=FILE:$MTR_SUITE_DIR/filekeys-data.key
--loose-file-key-management-filename=$MTR_SUITE_DIR/filekeys-data.enc
--loose-file-key-management-encryption-algorithm=aes_cbc
CREATE TABLE t(c VARCHAR(10)) ENGINE INNODB encrypted=yes;
INSERT INTO t VALUES('foobar1');
# xtrabackup backup
NOT FOUND /foobar1/ in xtrabackup_logfile
# expect NOT FOUND
INSERT INTO t VALUES('foobar2');
# xtrabackup prepare
# shutdown server
# remove datadir
# xtrabackup move back
# restart server
NOT FOUND /foobar1/ in xtrabackup_logfile
# expect NOT FOUND
SELECT * FROM t;
c
foobar1
DROP TABLE t;
source include/have_file_key_management.inc;
CREATE TABLE t(c VARCHAR(10)) ENGINE INNODB encrypted=yes;
INSERT INTO t VALUES('foobar1');
echo # xtrabackup backup;
let $targetdir=$MYSQLTEST_VARDIR/tmp/backup;
--disable_result_log
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir;
--enable_result_log
--let SEARCH_RANGE = 10000000
--let SEARCH_PATTERN=foobar1
--let SEARCH_FILE=$targetdir/xtrabackup_logfile
--source include/search_pattern_in_file.inc
--echo # expect NOT FOUND
INSERT INTO t VALUES('foobar2');
echo # xtrabackup prepare;
--disable_result_log
exec $XTRABACKUP --prepare --target-dir=$targetdir;
exec $XTRABACKUP --defaults-file=$targetdir/backup-my.cnf --stats --datadir=$targetdir ;
-- source include/restart_and_restore.inc
--enable_result_log
#
# Recheck that plain text data (
# in not in the log, after prepare
# (MDEV-11538)
--let SEARCH_RANGE = 10000000
--let SEARCH_PATTERN=foobar1
--let SEARCH_FILE=$targetdir/xtrabackup_logfile
--source include/search_pattern_in_file.inc
--echo # expect NOT FOUND
SELECT * FROM t;
DROP TABLE t;
rmdir $targetdir;
--plugin-load-add=$FILE_KEY_MANAGEMENT_SO
--innodb_strict_mode
--innodb_file_per_table
--innodb-encryption-rotate-key-age=2
--innodb-encryption-threads=4
--innodb-tablespaces-encryption
--loose-file-key-management
--loose-file-key-management-filename=$MYSQL_TEST_DIR/std_data/logkey.txt
\ No newline at end of file
CREATE TABLE film_text (
film_id SMALLINT NOT NULL,
title VARCHAR(255) NOT NULL,
description TEXT,
PRIMARY KEY (film_id),
FULLTEXT KEY idx_title_description (title,description),
FULLTEXT KEY (description),
FULLTEXT KEY (title)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 ENCRYPTED=YES;
# shutdown server
# remove datadir
# xtrabackup move back
# restart server
drop table film_text;
source include/have_file_key_management.inc;
CREATE TABLE film_text (
film_id SMALLINT NOT NULL,
title VARCHAR(255) NOT NULL,
description TEXT,
PRIMARY KEY (film_id),
FULLTEXT KEY idx_title_description (title,description),
FULLTEXT KEY (description),
FULLTEXT KEY (title)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 ENCRYPTED=YES;
let $targetdir=$MYSQLTEST_VARDIR/tmp/backup;
--disable_result_log
exec $INNOBACKUPEX --defaults-file=$MYSQLTEST_VARDIR/my.cnf --no-timestamp $targetdir;
exec $INNOBACKUPEX --apply-log --rebuild-indexes --rebuild-threads=2 $targetdir;
--source include/restart_and_restore.inc
--enable_result_log
drop table film_text;
SELECT COUNT(*) FROM PERCONA_SCHEMA.xtrabackup_history;
COUNT(*)
1
DROP TABLE PERCONA_SCHEMA.xtrabackup_history;
DROP DATABASE PERCONA_SCHEMA;
let $targetdir=$MYSQLTEST_VARDIR/tmp/backup;
--disable_result_log
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --history=foo --backup --target-dir=$targetdir;
--enable_result_log
SELECT COUNT(*) FROM PERCONA_SCHEMA.xtrabackup_history;
DROP TABLE PERCONA_SCHEMA.xtrabackup_history;
DROP DATABASE PERCONA_SCHEMA;
rmdir $targetdir;
CREATE TABLE t1(c1 INT, b CHAR(20)) ENGINE=INNODB PAGE_COMPRESSED=1;
CREATE PROCEDURE innodb_insert_proc (REPEAT_COUNT INT)
BEGIN
DECLARE CURRENT_NUM INT;
SET CURRENT_NUM = 0;
WHILE CURRENT_NUM < REPEAT_COUNT DO
INSERT INTO t1 VALUES(CURRENT_NUM,'TESTING..');
SET CURRENT_NUM = CURRENT_NUM + 1;
END WHILE;
END//
COMMIT;
SET AUTOCOMMIT=0;
CALL innodb_insert_proc(5000);
COMMIT;
SELECT (VARIABLE_VALUE >= 0) AS HAVE_COMPRESSED_PAGES
FROM INFORMATION_SCHEMA.GLOBAL_STATUS
WHERE VARIABLE_NAME = 'INNODB_NUM_PAGES_PAGE_COMPRESSED';
HAVE_COMPRESSED_PAGES
1
# xtrabackup backup
# xtrabackup prepare
ALTER TABLE t1 DISCARD TABLESPACE;
ALTER TABLE t1 IMPORT TABLESPACE;
SELECT COUNT(*) FROM t1;
COUNT(*)
5000
DROP PROCEDURE innodb_insert_proc;
DROP TABLE t1;
CREATE TABLE t1(c1 INT, b CHAR(20)) ENGINE=INNODB PAGE_COMPRESSED=1;
DELIMITER //;
CREATE PROCEDURE innodb_insert_proc (REPEAT_COUNT INT)
BEGIN
DECLARE CURRENT_NUM INT;
SET CURRENT_NUM = 0;
WHILE CURRENT_NUM < REPEAT_COUNT DO
INSERT INTO t1 VALUES(CURRENT_NUM,'TESTING..');
SET CURRENT_NUM = CURRENT_NUM + 1;
END WHILE;
END//
DELIMITER ;//
COMMIT;
SET AUTOCOMMIT=0;
CALL innodb_insert_proc(5000);
COMMIT;
SELECT (VARIABLE_VALUE >= 0) AS HAVE_COMPRESSED_PAGES
FROM INFORMATION_SCHEMA.GLOBAL_STATUS
WHERE VARIABLE_NAME = 'INNODB_NUM_PAGES_PAGE_COMPRESSED';
echo # xtrabackup backup;
let $targetdir=$MYSQLTEST_VARDIR/tmp/backup;
--disable_result_log
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup "--tables=test.*1" --target-dir=$targetdir;
echo # xtrabackup prepare;
exec $XTRABACKUP --prepare --export --target-dir=$targetdir;
--enable_result_log
ALTER TABLE t1 DISCARD TABLESPACE;
let $MYSQLD_DATADIR= `select @@datadir`;
copy_file $targetdir/test/t1.ibd $MYSQLD_DATADIR/test/t1.ibd;
copy_file $targetdir/test/t1.cfg $MYSQLD_DATADIR/test/t1.cfg;
ALTER TABLE t1 IMPORT TABLESPACE;
SELECT COUNT(*) FROM t1;
DROP PROCEDURE innodb_insert_proc;
DROP TABLE t1;
rmdir $targetdir;
CREATE TABLE t1(a INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1), (2), (3);
CREATE TABLE t2(a INT) ENGINE=InnoDB;
INSERT INTO t2 VALUES (4), (5), (6);
CREATE TABLE p (
a int
) ENGINE=InnoDB
PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (100),
PARTITION p1 VALUES LESS THAN (200),
PARTITION p2 VALUES LESS THAN (300),
PARTITION p3 VALUES LESS THAN (400));
INSERT INTO p VALUES (1), (101), (201), (301);
CREATE TABLE isam_t1(a INT) ENGINE=MyISAM;
INSERT INTO isam_t1 VALUES (1), (2), (3);
CREATE TABLE isam_t2(a INT) ENGINE=MyISAM;
INSERT INTO isam_t2 VALUES (4), (5), (6);
CREATE TABLE isam_p (
a int
) ENGINE=MyISAM
PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (100),
PARTITION p1 VALUES LESS THAN (200),
PARTITION p2 VALUES LESS THAN (300),
PARTITION p3 VALUES LESS THAN (400));
INSERT INTO isam_p VALUES (1), (101), (201), (301);
DROP TABLE t1;
DROP TABLE t2;
CREATE TABLE t2(a INT) ENGINE=InnoDB;
INSERT INTO t2 VALUES (40), (50), (60);
ALTER TABLE p DROP PARTITION p0;
ALTER TABLE p DROP PARTITION p1;
ALTER TABLE p ADD PARTITION (PARTITION p4 VALUES LESS THAN (500));
ALTER TABLE p ADD PARTITION (PARTITION p5 VALUES LESS THAN (600));
INSERT INTO p VALUES (401), (501);
DROP TABLE isam_t1;
DROP TABLE isam_t2;
CREATE TABLE isam_t2(a INT) ENGINE=MyISAM;
INSERT INTO isam_t2 VALUES (40), (50), (60);
ALTER TABLE isam_p DROP PARTITION p0;
ALTER TABLE isam_p DROP PARTITION p1;
ALTER TABLE isam_p ADD PARTITION (PARTITION p4 VALUES LESS THAN (500));
ALTER TABLE isam_p ADD PARTITION (PARTITION p5 VALUES LESS THAN (600));
INSERT INTO isam_p VALUES (401), (501);
# shutdown server
# remove datadir
# xtrabackup move back
# restart server
SELECT * from p;
a
201
301
401
501
SELECT * from isam_p;
a
201
301
401
501
DROP TABLE isam_p;
DROP TABLE isam_t2;
DROP TABLE p;
DROP TABLE t2;
--source include/have_partition.inc
CREATE TABLE t1(a INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1), (2), (3);
CREATE TABLE t2(a INT) ENGINE=InnoDB;
INSERT INTO t2 VALUES (4), (5), (6);
CREATE TABLE p (
a int
) ENGINE=InnoDB
PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (100),
PARTITION p1 VALUES LESS THAN (200),
PARTITION p2 VALUES LESS THAN (300),
PARTITION p3 VALUES LESS THAN (400));
INSERT INTO p VALUES (1), (101), (201), (301);
CREATE TABLE isam_t1(a INT) ENGINE=MyISAM;
INSERT INTO isam_t1 VALUES (1), (2), (3);
CREATE TABLE isam_t2(a INT) ENGINE=MyISAM;
INSERT INTO isam_t2 VALUES (4), (5), (6);
CREATE TABLE isam_p (
a int
) ENGINE=MyISAM
PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (100),
PARTITION p1 VALUES LESS THAN (200),
PARTITION p2 VALUES LESS THAN (300),
PARTITION p3 VALUES LESS THAN (400));
INSERT INTO isam_p VALUES (1), (101), (201), (301);
let $targetdir=$MYSQLTEST_VARDIR/tmp;
--disable_result_log
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --no-timestamp --backup --target-dir=$targetdir/full;
--enable_result_log
DROP TABLE t1;
DROP TABLE t2;
CREATE TABLE t2(a INT) ENGINE=InnoDB;
INSERT INTO t2 VALUES (40), (50), (60);
ALTER TABLE p DROP PARTITION p0;
ALTER TABLE p DROP PARTITION p1;
ALTER TABLE p ADD PARTITION (PARTITION p4 VALUES LESS THAN (500));
ALTER TABLE p ADD PARTITION (PARTITION p5 VALUES LESS THAN (600));
INSERT INTO p VALUES (401), (501);
DROP TABLE isam_t1;
DROP TABLE isam_t2;
CREATE TABLE isam_t2(a INT) ENGINE=MyISAM;
INSERT INTO isam_t2 VALUES (40), (50), (60);
ALTER TABLE isam_p DROP PARTITION p0;
ALTER TABLE isam_p DROP PARTITION p1;
ALTER TABLE isam_p ADD PARTITION (PARTITION p4 VALUES LESS THAN (500));
ALTER TABLE isam_p ADD PARTITION (PARTITION p5 VALUES LESS THAN (600));
INSERT INTO isam_p VALUES (401), (501);
--disable_result_log
exec $INNOBACKUPEX --defaults-file=$MYSQLTEST_VARDIR/my.cnf --incremental --no-timestamp --incremental-basedir=$targetdir/full $targetdir/inc;
exec $INNOBACKUPEX --defaults-file=$MYSQLTEST_VARDIR/my.cnf --apply-log --redo-only $targetdir/full;
exec $INNOBACKUPEX --defaults-file=$MYSQLTEST_VARDIR/my.cnf --apply-log --redo-only --incremental-dir=$targetdir/inc $targetdir/full;
exec $INNOBACKUPEX --defaults-file=$MYSQLTEST_VARDIR/my.cnf --apply-log $targetdir/full;
let $targetdir=$targetdir/full;
-- source include/restart_and_restore.inc
--enable_result_log
SELECT * from p;
SELECT * from isam_p;
DROP TABLE isam_p;
DROP TABLE isam_t2;
DROP TABLE p;
DROP TABLE t2;
rmdir $MYSQLTEST_VARDIR/tmp/full;
rmdir $MYSQLTEST_VARDIR/tmp/inc;
CREATE TABLE t(i INT) ENGINE INNODB;
INSERT INTO t VALUES(1);
# xtrabackup backup to stream
# xbstream extract
# xtrabackup prepare
# shutdown server
# remove datadir
# xtrabackup move back
# restart server
SELECT * FROM t;
i
1
DROP TABLE t;
CREATE TABLE t(i INT) ENGINE INNODB;
INSERT INTO t VALUES(1);
let $targetdir=$MYSQLTEST_VARDIR/tmp/backup;
mkdir $targetdir;
let $streamfile=$MYSQLTEST_VARDIR/tmp/backup.xb;
echo # xtrabackup backup to stream;
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --stream=xbstream > $streamfile 2>$targetdir/backup_stream.log;
echo # xbstream extract;
--disable_result_log
exec $XBSTREAM -x -C $targetdir < $streamfile;
echo # xtrabackup prepare;
exec $XTRABACKUP --prepare --target-dir=$targetdir;
-- source include/restart_and_restore.inc
--enable_result_log
SELECT * FROM t;
DROP TABLE t;
rmdir $targetdir;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment