| 1 |
# ==== Purpose ==== |
| 2 |
# |
| 3 |
# Create a backup from a master , which at later point can be restored |
| 4 |
# successfully on slave. |
| 5 |
# |
| 6 |
# 1. Perform some DDL/DML operations on a master |
| 7 |
# 2. Create a backup from the member using mysqlpump |
| 8 |
# 3. Verify if that backup can be later restored successfully on a 2nd server |
| 9 |
# 4. See if that @@GLOBAL.GTID_EXECUTED is same on both servers. |
| 10 |
# 5. Set up replication.Perform some DDL/DML operations on the master. |
| 11 |
# 6. Cleanup |
| 12 |
# |
| 13 |
# ==== Related Bugs and Worklogs ==== |
| 14 |
# |
| 15 |
# Bug #23748432 MYSQLPUMP FULL LOGICAL BACKUPS UNUSABLE WITH GTID REPLICATION |
| 16 |
# |
| 17 |
--let $rpl_skip_start_slave= 1 |
| 18 |
# test is agnostic to binlog_format |
| 19 |
--source include/have_binlog_format_row.inc |
| 20 |
--source include/master-slave.inc |
| 21 |
|
| 22 |
# Create a table and insert data into it. |
| 23 |
CREATE DATABASE db; |
| 24 |
USE db; |
| 25 |
CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB; |
| 26 |
INSERT INTO t1 VALUES (0); |
| 27 |
INSERT INTO t1 VALUES (1); |
| 28 |
UPDATE t1 SET c1=2 WHERE c1=0; |
| 29 |
SET GTID_NEXT= 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:1'; |
| 30 |
INSERT INTO t1 VALUES (3); |
| 31 |
SET GTID_NEXT= 'AUTOMATIC'; |
| 32 |
|
| 33 |
--let $master_executed = `SELECT @@GLOBAL.GTID_EXECUTED` |
| 34 |
|
| 35 |
# Create a backup using mysqlpump |
| 36 |
--let $server1_backup_file= backup_server1.sql |
| 37 |
# Use mysqlpump client to get a dump of server1 |
| 38 |
--exec $MYSQL_PUMP --user=root --host=127.0.0.1 --port=$MASTER_MYPORT --all-databases --exclude-databases=mysql,mtr > $server_1_datadir/$server1_backup_file |
| 39 |
|
| 40 |
# Restore the backup onto a 2nd server |
| 41 |
--echo |
| 42 |
--source include/rpl_connection_slave.inc |
| 43 |
--exec $MYSQL --user=root --host=127.0.0.1 --port=$SLAVE_MYPORT < $server_1_datadir/$server1_backup_file |
| 44 |
|
| 45 |
# See if the data has been properly restored on server2 |
| 46 |
--let $assert_cond = "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$master_executed" |
| 47 |
--let $assert_text = 'gtid_executed should be the same on master and slave' |
| 48 |
--source include/assert.inc |
| 49 |
|
| 50 |
--echo |
| 51 |
--let $diff_tables= master:db.t1, slave:db.t1 |
| 52 |
--source include/diff_tables.inc |
| 53 |
|
| 54 |
# Start replication on slave |
| 55 |
--echo |
| 56 |
--source include/start_slave.inc |
| 57 |
|
| 58 |
# Drop table |
| 59 |
--echo |
| 60 |
--source include/rpl_connection_master.inc |
| 61 |
|
| 62 |
DROP DATABASE db; |
| 63 |
|
| 64 |
--remove_file $server_1_datadir/$server1_backup_file |
| 65 |
--source include/rpl_end.inc |