innodb热备工具之ibbackup
2010-09-17 11:14:59 阿炯

InnoDB Hot Backup is the ideal solution for online backups of InnoDB and MyISAM tables in MySQL databases — and for setting up replication. InnoDB Hot Backup allows you to backup a running MySQL database, including InnoDB and MyISAM tables, with minimal disruption to operations. You get a consistent copy of your database, as if the copy were taken at a precise point in time. While InnoDB Hot Backup copies InnoDB tables, reads and writes to both InnoDB and MyISAM tables can continue. During the copying of MyISAM tables, reads (but not writes) are permitted.

In addition, InnoDB Hot Backup supports creating compressed backup files, and performing backups of subsets of InnoDB tables. In conjunction with MySQL’s binlog, users can perform point in time recovery. InnoDB Hot Backup is also the ideal method of setting up new slaves if you use the MySQL replication on InnoDB tables.

innodb hot backup是一个商用的可执行文件。不过可以申请30天试用下。ibbackup 只需要识别简单的几个 InnoDB 相关参数即可。它在备份时需要用到2个配置文件,一个是指定在线运行的信息,一个是备份相关信息。

相比mysql自身的mysqldump 导入导出工具来说有以下优点:
1、物理备份。
2、还原速度快。

而mysqldump在并发小的时候还可以用下。缺点如下:
1、逻辑备份。
2、还原速度慢。

而LVM则可以和innodb hot backup 非常相似。

ibbackup 备份和恢复是基于物理块级,把每个表空间文件做一个干净的备份,并且支持备份同时有事务提交,以得到最新的数据备份。因此 ibbackup 产生的备份文件如果不经压缩(不管是备份时压缩,还是事后压缩),那么占用的空间会比较大。

mysqldump 可以用 single-transaction 来得到一致性备份,但是备份的数据是发起操作的瞬间快照,之后提交的事务都不会在备份中体现。mysqldump 可能会导致 log purge 停滞很长时间,使得mysql的响应变得非常慢,这点 ibbackup 就可以避免。mysqldump 产生的备份文件相对 ibbackup 生成的小多了。还原时,ibbackup 相比重新导入sql文件会快不少,在这方面,ibbackup 有非常大的优势。

不过innodb hot backup的缺点也是有的,就是只备份INNODB的表空间以及生成新的REDO 日志。对于表结构的备份可以直接用mysqldump来个快速逻辑备份, 或者可以用 INNODB 官方给的开源PERL 脚本来配合备份表结构。

官方主页:http://www.innodb.com