增量备份点-------------错误删除点------------------------------》恢复数据
数据还在持续写入
模拟
1.full back (3 rows) 3pm 前一天的备份
2,insert 3 rows 5pm 第二天新增数据
3,delete from table 7pm 误操作
4,insert 3 rows 8pm 不断新增数据
5,recovery databases 9pm 恢复数据
/mysqldump -uroot -p db1 > /root/mysqlbackup/t2.sql 备份
/etc/init.d/mysqld restart 模拟生成新的二进制日志
insert into t2 values (4,40),(5,50),(6,60); 新增数据
delete from t2; 误操作
insert into t2 values (7,70),(8,80),(9,90); 不断新增数据
开始恢复
mysql -uroot -p db1 < /root/mysqlbackup/t2.sql
下面跳过delete 这条记录,恢复其他position的记录
# at 526
#150512 7:50:58 server id 1 end_log_pos 640 CRC32 0x4f6549a3 Querythread_id=1exec_time=0error_code=0
SET TIMESTAMP=1431388258/*!*/;
insert into t2 values (4,40),(5,50),(6,60)
/*!*/;
# at 640
#150512 7:50:58 server id 1 end_log_pos 671 CRC32 0x253a2239 Xid = 60
COMMIT/*!*/;
# at 671
#150512 7:52:11 server id 1 end_log_pos 748 CRC32 0x7617cce8 Querythread_id=1exec_time=0error_code=0
SET TIMESTAMP=1431388331/*!*/;
BEGIN
/*!*/;
# at 748
#150512 7:52:11 server id 1 end_log_pos 834 CRC32 0x112802bc Querythread_id=1exec_time=0error_code=0
SET TIMESTAMP=1431388331/*!*/;
delete from t2
/*!*/;
# at 834
#150512 7:52:11 server id 1 end_log_pos 865 CRC32 0x8895c353 Xid = 62
COMMIT/*!*/;
# at 865
#150512 7:52:38 server id 1 end_log_pos 942 CRC32 0xa34076dd Querythread_id=1exec_time=0error_code=0
SET TIMESTAMP=1431388358/*!*/;
BEGIN
/*!*/;
# at 942
#150512 7:52:38 server id 1 end_log_pos 1056 CRC32 0xa1c9c171 Querythread_id=1exec_time=0error_code=0
SET TIMESTAMP=1431388358/*!*/;
insert into t2 values (7,70),(8,80),(9,90)
/*!*/;
# at 1056
#150512 7:52:38 server id 1 end_log_pos 1087 CRC32 0x73a98385 Xid = 64
COMMIT/*!*/;
bin/mysqlbinlog --start-position=526 --stop-position=640 data/mysql-bin.000004 | mysql -uroot -p
bin/mysqlbinlog --start-position=942 --stop-position=1056 data/mysql-bin.000004 | mysql -uroot -p
本文出自 “crazy_sir” 博客,请务必保留此出处http://douya.blog.51cto.com/6173221/1651285
原文地址:http://douya.blog.51cto.com/6173221/1651285