innobackupex备份与xtrabackup备份对比

时间:2021-03-09 10:13:19

innobackup备份时,会启动xtrabackup相关脚本,如下:

innobackupex --socket=/home/mysql/run/mysql.sock --user=root --password=123456  /tmp
... ...
innobackupex: Starting ibbackup with command: xtrabackup_56 --defaults-group="mysqld" --backup --suspend-at-end --target-dir=/tmp/2015-08-14_16-39-57 --tmpdir=/tmp
innobackupex: Waiting for ibbackup (pid=38180) to suspend
innobackupex: Suspend file '/tmp/2015-08-14_16-39-57/xtrabackup_suspended_2'
... ...

xtra全备

xtrabackup --backup --target-dir=/tmp
-rw-r-----. 1 root root 146800640 Aug 14 17:35 ibdata1
drwx------. 2 root root 4096 Aug 14 17:35 mtms
drwx------. 2 root root 4096 Aug 14 17:35 bbp
drwx------. 2 root root 4096 Aug 14 17:35 lmis
drwx------. 2 root root 4096 Aug 14 17:35 test
drwx------. 2 root root 4096 Aug 14 17:35 mysql
-rw-r-----. 1 root root 2560 Aug 14 17:35 xtrabackup_logfile
-rw-r-----. 1 root root 97 Aug 14 17:35 xtrabackup_checkpoints
ll lmis
total 61536
-rw-r-----. 1 root root 98304 Aug 14 17:35 md_goods_type.ibd
-rw-r-----. 1 root root 62914560 Aug 14 17:35 md_product.ibd
inno全备

innobackupex --socket=/home/mysql/run/mysql.sock --user=root --password=123456  /tmp
ll /tmp
-rw-r--r--. 1 root root 57 Aug 14 16:39 percona-version-check
drwxr-xr-x. 9 root root 4096 Aug 14 16:40 2015-08-14_16-39-57
ll /tmp/2015-08-14_16-39-57

-rw-r--r--. 1 root root 359 Aug 14 16:39 backup-my.cnf
drwx------. 2 root root 4096 Aug 14 16:40 bbp
-rw-r-----. 1 root root 146800640 Aug 14 16:40 ibdata1
drwx------. 2 root root 4096 Aug 14 16:40 lmis
drwx------. 2 root root 4096 Aug 14 16:40 mtms
drwxr-xr-x. 2 root root 4096 Aug 14 16:40 myisam
drwx------. 2 root root 4096 Aug 14 16:40 mysql
drwxr-xr-x. 2 root root 4096 Aug 14 16:40 performance_schema
drwx------. 2 root root 4096 Aug 14 16:40 test
-rw-r--r--. 1 root root 13 Aug 14 16:40 xtrabackup_binary
-rw-r--r--. 1 root root 23 Aug 14 16:40 xtrabackup_binlog_info
-rw-r-----. 1 root root 97 Aug 14 16:40 xtrabackup_checkpoints
-rw-r-----. 1 root root 2560 Aug 14 16:40 xtrabackup_logfile
ll /tmp/2015-08-14_16-39-57/lmis
-rw-r-----. 1 root root 61 Aug 14 16:40 db.opt
-rw-r-----. 1 root root 8918 Aug 14 16:40 md_goods_type.frm
-rw-r-----. 1 root root 98304 Aug 14 16:40 md_goods_type.ibd
-rw-r-----. 1 root root 14557 Aug 14 16:40 md_product.frm
-rw-r-----. 1 root root 62914560 Aug 14 16:40 md_product.ibd
cat /tmp/2015-08-14_16-39-57/backup-my.cnf
# This MySQL options file was generated by innobackupex.
# The MySQL server
[mysqld]
innodb_checksum_algorithm=innodb
innodb_log_checksum_algorithm=innodb
innodb_data_file_path=ibdata1:10M:autoextend
innodb_log_files_in_group=2
innodb_log_file_size=1073741824
innodb_fast_checksum=0
innodb_page_size=16384
innodb_log_block_size=512
innodb_undo_tablespaces=0

innobackupex与xtrabackup的区别:

1、inno备份包含myisam引擎的表(performance_schema和myisam两个库表都为myisam引擎),但注意会加锁

2、inno会备份库信息(db.opt文件)及frm表(.frm文件)结构

3、inno备份的backup-my.cnf文件记录innodb的一些参数

4、inno备份binlog相关信息

所以一般使用innobackupex进行数据库备份。