备份脚本:
innobackupex \
--defaults-file="/export/servers/mysql/etc/my.cnf" \
--host="localhost" \
--port=3358 \
--user='admin' \
--password='admin_psw' \
--slave-info \
--safe-slave-backup \
"/export/bak/"
备份操作访问MySQL记录:
2019-06-05T14:20:43.620313+08:00 1328 Connect root@localhost on using Socket 2019-06-05T14:20:43.620472+08:00 1328 Query set autocommit=1 2019-06-05T14:20:43.620585+08:00 1328 Query SET SESSION wait_timeout=2147483 2019-06-05T14:20:43.620722+08:00 1328 Query SELECT CONCAT(@@hostname, @@port) 2019-06-05T14:20:43.620922+08:00 1328 Quit 2019-06-05T14:20:43.622332+08:00 1329 Connect root@localhost on using Socket 2019-06-05T14:20:43.622387+08:00 1329 Query SET SESSION wait_timeout=2147483 2019-06-05T14:20:43.622454+08:00 1329 Query SHOW VARIABLES 2019-06-05T14:20:43.624597+08:00 1329 Query SHOW ENGINE INNODB STATUS 2019-06-05T14:20:43.625395+08:00 1329 Query SELECT CONCAT(table_schema, '/', table_name), engine FROM information_schema.tables WHERE engine NOT IN ( 'MyISAM', 'InnoDB', 'CSV', 'MRG_MYISAM' ) AND table_schema NOT IN ( 'performance_schema', 'information_schema', 'mysql' ) 2019-06-05T14:20:46.878898+08:00 1329 Query SHOW SLAVE STATUS 2019-06-05T14:20:46.879139+08:00 1329 Query SET SESSION lock_wait_timeout=31536000 2019-06-05T14:20:46.879229+08:00 1329 Query FLUSH NO_WRITE_TO_BINLOG TABLES 2019-06-05T14:20:46.879381+08:00 1329 Query FLUSH TABLES WITH READ LOCK 2019-06-05T14:20:46.964749+08:00 1329 Query SHOW VARIABLES 2019-06-05T14:20:46.967103+08:00 1329 Query SHOW SLAVE STATUS 2019-06-05T14:20:46.967201+08:00 1329 Query SHOW MASTER STATUS 2019-06-05T14:20:46.967244+08:00 1329 Query SHOW VARIABLES 2019-06-05T14:20:46.969062+08:00 1329 Query FLUSH NO_WRITE_TO_BINLOG ENGINE LOGS 2019-06-05T14:20:47.169430+08:00 1329 Query UNLOCK TABLES 2019-06-05T14:20:47.170049+08:00 1329 Query SELECT UUID() 2019-06-05T14:20:47.170119+08:00 1329 Query SELECT VERSION() 2019-06-05T14:20:47.374226+08:00 1329 Quit
备份操作输出日志:
190605 14:28:14 innobackupex: Starting the backup operation
IMPORTANT: Please check that the backup run completes successfully.
At the end of a successful backup run innobackupex
prints "completed OK!".
190605 14:28:14 version_check Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_group=xtrabackup;host=localhost;port=3358' as 'admin' (using password: YES).
190605 14:28:14 version_check Connected to MySQL server
190605 14:28:14 version_check Executing a version check against the server...
190605 14:28:14 version_check Done.
190605 14:28:14 Connecting to MySQL server host: localhost, user: admin, password: set, port: 3358, socket: not set
Using server version 5.7.24-log
innobackupex version 2.4.8 based on MySQL server 5.7.13 Linux (x86_64) (revision id: 97330f7)
xtrabackup: uses posix_fadvise().
xtrabackup: cd to /export/data/mysql/data/
xtrabackup: open files limit requested 65535, set to 196605
xtrabackup: using the following InnoDB configuration:
xtrabackup: innodb_data_home_dir = /export/data/mysql/data
xtrabackup: innodb_data_file_path = ibdata1:1024M:autoextend
xtrabackup: innodb_log_group_home_dir = /export/data/mysql/data
xtrabackup: innodb_log_files_in_group = 3
xtrabackup: innodb_log_file_size = 1073741824
xtrabackup: using O_DIRECT
InnoDB: Number of pools: 1
190605 14:28:14 >> log scanned up to (2510555)
InnoDB: Opened 4 undo tablespaces
InnoDB: 0 undo tablespaces made active
xtrabackup: Generating a list of tablespaces
InnoDB: Allocated tablespace ID 27 for db001/tb001, old maximum was 4
190605 14:28:14 [01] Copying /export/data/mysql/data/ibdata1 to /export/bak/2019-06-05_14-28-14/ibdata1
190605 14:28:15 >> log scanned up to (2510555)
190605 14:28:16 >> log scanned up to (2510555)
190605 14:28:17 [01] ...done
190605 14:28:17 [01] Copying /export/data/mysql/undo/undo001 to /export/bak/2019-06-05_14-28-14/undo001
190605 14:28:17 [01] ...done
190605 14:28:17 [01] Copying /export/data/mysql/undo/undo002 to /export/bak/2019-06-05_14-28-14/undo002
190605 14:28:17 [01] ...done
190605 14:28:17 [01] Copying /export/data/mysql/undo/undo003 to /export/bak/2019-06-05_14-28-14/undo003
190605 14:28:17 [01] ...done
190605 14:28:17 [01] Copying /export/data/mysql/undo/undo004 to /export/bak/2019-06-05_14-28-14/undo004
190605 14:28:17 [01] ...done
190605 14:28:17 [01] Copying ./db001/tb001.ibd to /export/bak/2019-06-05_14-28-14/db001/tb001.ibd
190605 14:28:17 [01] ...done
Not checking slave open temp tables for --safe-slave-backup because host is not a slave
190605 14:28:17 Executing FLUSH NO_WRITE_TO_BINLOG TABLES...
190605 14:28:17 Executing FLUSH TABLES WITH READ LOCK...
190605 14:28:17 Starting to backup non-InnoDB tables and files
190605 14:28:17 [01] Copying ./db001/db.opt to /export/bak/2019-06-05_14-28-14/db001/db.opt
190605 14:28:17 [01] ...done
190605 14:28:17 [01] Copying ./db001/tb002.MYD to /export/bak/2019-06-05_14-28-14/db001/tb002.MYD
190605 14:28:17 [01] ...done
190605 14:28:17 [01] Copying ./db001/tb002.frm to /export/bak/2019-06-05_14-28-14/db001/tb002.frm
190605 14:28:17 [01] ...done
190605 14:28:17 [01] Copying ./db001/tb002.MYI to /export/bak/2019-06-05_14-28-14/db001/tb002.MYI
190605 14:28:17 [01] ...done
190605 14:28:17 [01] Copying ./db001/tb001.frm to /export/bak/2019-06-05_14-28-14/db001/tb001.frm
190605 14:28:17 [01] ...done
190605 14:28:18 [01] Copying ./mysql/innodb_index_stats.frm to /export/bak/2019-06-05_14-28-14/mysql/innodb_index_stats.frm
190605 14:28:18 [01] ...done
190605 14:28:18 [01] Copying ./mysql/gtid_executed.frm to /export/bak/2019-06-05_14-28-14/mysql/gtid_executed.frm
190605 14:28:18 [01] ...done
190605 14:28:18 Finished backing up non-InnoDB tables and files
190605 14:28:18 [00] Writing /export/bak/2019-06-05_14-28-14/xtrabackup_binlog_info
190605 14:28:18 [00] ...done
190605 14:28:18 Executing FLUSH NO_WRITE_TO_BINLOG ENGINE LOGS...
xtrabackup: The latest check point (for incremental): '2510546'
xtrabackup: Stopping log copying thread.
.190605 14:28:18 >> log scanned up to (2510555)
190605 14:28:18 Executing UNLOCK TABLES
190605 14:28:18 All tables unlocked
190605 14:28:18 [00] Copying ib_buffer_pool to /export/bak/2019-06-05_14-28-14/ib_buffer_pool
190605 14:28:18 [00] ...done
190605 14:28:18 Backup created in directory '/export/bak/2019-06-05_14-28-14/'
MySQL binlog position: filename 'mysql-bin.000002', position '6503', GTID of the last change '38787e3d-86a3-11e9-b1b1-246e965eae3d:1-21'
190605 14:28:18 [00] Writing /export/bak/2019-06-05_14-28-14/backup-my.cnf
190605 14:28:18 [00] ...done
190605 14:28:18 [00] Writing /export/bak/2019-06-05_14-28-14/xtrabackup_info
190605 14:28:18 [00] ...done
xtrabackup: Transaction log of lsn (2510546) to (2510555) was copied.
190605 14:28:18 completed OK!
在备份过程中,先拷贝Innodb表数据,然后在备份非InnoDB表时备份InnoDB表的表结构。