mariadb/mysql-test/t/rpl_mysqldump_slave.test
Magne Mahre 6eb797f973 BUG #8368 "mysqldump needs --slave-data option"
Added this option, named as "--dump-slave". The purpose of this option is to be
able to produce a dump from a slave used for making backups of the master. Originally,
dumping from the main master was fine, but as more data accumulated, the dump process
would take over 30 minutes, locking up the master database hence website for 30 minutes.
A slave dedicated to producing backups was the answer, but I needed a dump that could be

used to restore a slave instantly and in order to do that, it has to have three things 
contained in the dump:
  
  1. "STOP SLAVE;" at the beginning
  2. "CHANGE MASTER TO ...<the master - info from 'show slave status'>"
  3. "START SLAVE;" at the end
  
These options in this changeset contain this.
  
  --stop-slave adds "STOP SLAVE" to the beginning of the dump and "STOP SLAVE" 
  to the end of the dump.
  
  --include-host gives the user the option to have the host explicitely added
  to the "CHANGE MASTER TO ..." line.
  
  --dump-slave adds the "CHANGE MASTER ..." to the dump representing not the slave's
  master binlog info, but the slave's master's info from "SHOW SLAVE STATUS"
2009-11-04 14:31:03 +01:00

25 lines
848 B
Text

source include/master-slave.inc;
--echo #
--echo # New --dump-slave, --apply-slave-statements functionality
--echo #
# There is a gap between when START SLAVE returns and when MASTER_LOG_FILE and
# MASTER_LOG_POS are set. Ensure that we don't call SHOW SLAVE STATUS during
# that gap.
--sync_slave_with_master
connection master;
use test;
connection slave;
# Execute mysqldump with --dump-slave
--exec $MYSQL_DUMP_SLAVE --compact --dump-slave test
# Execute mysqldump with --dump-slave and --apply-slave-statements
--exec $MYSQL_DUMP_SLAVE --compact --dump-slave --apply-slave-statements test
--replace_result $MASTER_MYPORT MASTER_MYPORT
# Execute mysqldump with --dump-slave ,--apply-slave-statements and --include-master-host-port
--exec $MYSQL_DUMP_SLAVE --compact --dump-slave --apply-slave-statements --include-master-host-port test