Debian Codegraph @

mysql-test/suite/mariabackup/partial.test

raw
1 #--source include/innodb_page_size.inc
2
3 # Export single table from backup
4 # (xtrabackup with --prepare --export)
5
6 CREATE TABLE t1(i INT) ENGINE INNODB;
7 INSERT INTO t1 VALUES(1);
8 CREATE TABLE t21(i INT) ENGINE INNODB;
9 INSERT INTO t21 VALUES(1);
10
11 CREATE TABLE t2(i int) ENGINE INNODB;
12
13 echo # xtrabackup backup;
14
15 let targetdir=$MYSQLTEST_VARDIR/tmp/backup;
16 --disable_result_log
17 exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --parallel=10 "--tables=test.*1" --target-dir=$targetdir --innodb_log_checkpoint_now=1;
18 --enable_result_log
19 list_files $targetdir/test *.ibd;
20 list_files $targetdir/test *.new;
21
22 # Inject a junk .ibd file into backup dir to
23 # see if prepare does not choke on it.
24 write_file $targetdir/test/junk.ibd;
25 EOF
26 write_file $targetdir/test/junk.frm;
27 EOF
28
29 let server_cnf=$targetdir/server.cnf;
30 copy_file $MYSQLTEST_VARDIR/my.cnf $server_cnf;
31
32 # Emulate server config file turnes on binary logs
33 perl;
34 my $binlog_path="$ENV{'targetdir'}/mysqld-bin";
35 my $config_path=$ENV{'server_cnf'};
36 open(my $fd, '>>', "$config_path");
37 print $fd "\n[mysqld]\n";
38 print $fd "log-bin=$binlog_path\n";
39 close $fd;
40 EOF
41
42 echo # xtrabackup prepare;
43 --disable_result_log
44 exec $XTRABACKUP --defaults-file=$server_cnf --defaults-group-suffix=.1 --prepare --export --target-dir=$targetdir;
45 --enable_result_log
46
47 list_files $targetdir/test *.cfg;
48 # There must not be binary logs created on --prepare step
49 list_files $targetdir/ mysqld-bin.*;
50
51 let $MYSQLD_DATADIR= `select @@datadir`;
52 ALTER TABLE t1 DISCARD TABLESPACE;
53 copy_file $targetdir/test/t1.ibd $MYSQLD_DATADIR/test/t1.ibd;
54 copy_file $targetdir/test/t1.cfg $MYSQLD_DATADIR/test/t1.cfg;
55 ALTER TABLE t1 IMPORT TABLESPACE;
56
57 SELECT * FROM t1;
58
59 --echo # MDEV-33023 Crash in mariadb-backup --prepare --export after --prepare
60 --disable_result_log
61 exec $XTRABACKUP --defaults-file=$server_cnf --defaults-group-suffix=.1 --prepare --target-dir=$targetdir;
62 exec $XTRABACKUP --defaults-file=$server_cnf --defaults-group-suffix=.1 --prepare --export --target-dir=$targetdir;
63 --enable_result_log
64
65 list_files $targetdir/test *.cfg;
66 # There must not be binary logs created on --prepare step
67 list_files $targetdir/ mysqld-bin.*;
68
69 let $MYSQLD_DATADIR= `select @@datadir`;
70 ALTER TABLE t1 DISCARD TABLESPACE;
71 copy_file $targetdir/test/t1.ibd $MYSQLD_DATADIR/test/t1.ibd;
72 copy_file $targetdir/test/t1.cfg $MYSQLD_DATADIR/test/t1.cfg;
73 ALTER TABLE t1 IMPORT TABLESPACE;
74
75 SELECT * FROM t1;
76
77 DROP TABLE t1;
78 DROP TABLE t2;
79 DROP TABLE t21;
80 rmdir $targetdir;
81
82 --echo #
83 --echo # MDEV-36287 maribackup ignores tables-file option
84 --echo #
85 CREATE TABLE t1(f1 INT NOT NULL)ENGINE=InnoDB;
86 CREATE TABLE t2(f1 INT NOT NULL)ENGINE=InnoDB;
87 INSERT INTO t1 values(1);
88 let targetdir=$MYSQLTEST_VARDIR/tmp/backup;
89 let tables_list=$MYSQLTEST_VARDIR/tmp/tables_list.out;
90 --echo # Only backup table t1 by creating tables_file
91 --exec echo "test.t1" > $tables_list
92
93 --echo # Backup with --tables-file option
94 --disable_result_log
95 exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --tables-file=$tables_list --target-dir=$targetdir;
96 --enable_result_log
97
98 --echo # table t2 is skipped. Shows only t1
99 --replace_result .new .ibd
100 list_files $targetdir/test;
101 DROP TABLE t2, t1;
102 rmdir $targetdir;
103 remove_file $tables_list;