little fix
This commit is contained in:
parent
fc7b07852e
commit
d5937ba51e
10
README.md
10
README.md
|
@ -66,7 +66,7 @@ DELETE FROM `test`.`test3` WHERE `addtime`='2016-12-10 13:03:38' AND `data`='eng
|
|||
|
||||
```bash
|
||||
|
||||
shell> python binlog2sql.py --flashback -h127.0.0.1 -P3306 -uadmin -p'admin' -dtest -ttest3 --start-file='mysql-bin.000002' --start-pos=763 --end-pos=1147
|
||||
shell> python binlog2sql.py --flashback -h127.0.0.1 -P3306 -uadmin -p'admin' -dtest -ttest3 --start-file='mysql-bin.000002' --start-position=763 --stop-position=1147
|
||||
|
||||
输出:
|
||||
INSERT INTO `test`.`test3`(`addtime`, `data`, `id`) VALUES ('2016-12-10 13:03:38', 'english', 4); #start 981 end 1147
|
||||
|
@ -89,11 +89,11 @@ UPDATE `test`.`test3` SET `addtime`='2016-12-10 13:03:22', `data`='中文', `id`
|
|||
|
||||
--start-file 起始解析文件。必须。
|
||||
|
||||
--start-pos start-file的起始解析位置。可选。默认为start-file的起始位置;
|
||||
--start-position/--start-pos start-file的起始解析位置。可选。默认为start-file的起始位置。
|
||||
|
||||
--end-file 末尾解析文件。可选。默认为start-file同一个文件。若解析模式为stop-never,此选项失效。
|
||||
--stop-file/--end-file 末尾解析文件。可选。默认为start-file同一个文件。若解析模式为stop-never,此选项失效。
|
||||
|
||||
--end-pos end-file的末尾解析位置。可选。默认为end-file的最末位置;若解析模式为stop-never,此选项失效。
|
||||
--stop-position/--end-pos stop-file的末尾解析位置。可选。默认为stop-file的最末位置;若解析模式为stop-never,此选项失效。
|
||||
|
||||
--start-datetime 从哪个时间点的binlog开始解析,格式必须为datetime,如'2016-11-11 11:11:11'。可选。默认不过滤。
|
||||
|
||||
|
@ -165,7 +165,7 @@ DELETE FROM `test`.`tbl` WHERE `addtime`='2016-12-12 00:00:00' AND `id`=4 AND `n
|
|||
3. 我们得到了误操作sql的准确位置在728-938之间,再根据位置进一步过滤,使用flashback模式生成回滚sql,检查回滚sql是否正确(注:真实环境下,此步经常会进一步筛选出需要的sql。结合grep、编辑器等)
|
||||
|
||||
```bash
|
||||
shell> python binlog2sql/binlog2sql.py -h127.0.0.1 -P3306 -uadmin -p'admin' -dtest -ttbl --start-file='mysql-bin.000052' --start-pos=3346 --end-pos=3556 -B > rollback.sql | cat
|
||||
shell> python binlog2sql/binlog2sql.py -h127.0.0.1 -P3306 -uadmin -p'admin' -dtest -ttbl --start-file='mysql-bin.000052' --start-position=3346 --stop-position=3556 -B > rollback.sql | cat
|
||||
输出:
|
||||
INSERT INTO `test`.`tbl`(`addtime`, `id`, `name`) VALUES ('2016-12-12 00:00:00', 4, '小李'); #start 728 end 938 time 2016-12-13 20:28:05
|
||||
INSERT INTO `test`.`tbl`(`addtime`, `id`, `name`) VALUES ('2016-12-13 20:25:00', 3, '小孙'); #start 728 end 938 time 2016-12-13 20:28:05
|
||||
|
|
|
@ -93,7 +93,7 @@ class Binlog2sql(object):
|
|||
else:
|
||||
print sql
|
||||
|
||||
if isinstance(binlogevent, RotateEvent) or isinstance(binlogevent, FormatDescriptionEvent):
|
||||
if not isinstance(binlogevent, RotateEvent) and not isinstance(binlogevent, FormatDescriptionEvent):
|
||||
lastPos = binlogevent.packet.log_pos
|
||||
if flagLastEvent:
|
||||
break
|
||||
|
|
|
@ -82,7 +82,7 @@ DELETE FROM `test`.`tbl` WHERE `addtime`='2016-12-12 00:00:00' AND `id`=4 AND `n
|
|||
3. 我们得到了误操作sql的准确位置在728-938之间,再根据位置过滤,使用flashback模式生成回滚sql,检查回滚sql是否正确(注:真实环境下,此步经常会进一步筛选出需要的sql。结合grep、编辑器等)
|
||||
|
||||
```bash
|
||||
shell> python binlog2sql/binlog2sql.py -h127.0.0.1 -P3306 -uadmin -p'admin' -dtest -ttbl --start-file='mysql-bin.000052' --start-pos=3346 --end-pos=3556 -B > rollback.sql | cat
|
||||
shell> python binlog2sql/binlog2sql.py -h127.0.0.1 -P3306 -uadmin -p'admin' -dtest -ttbl --start-file='mysql-bin.000052' --start-position=3346 --stop-position=3556 -B > rollback.sql | cat
|
||||
输出:
|
||||
INSERT INTO `test`.`tbl`(`addtime`, `id`, `name`) VALUES ('2016-12-12 00:00:00', 4, '小李'); #start 728 end 938 time 2016-12-13 20:28:05
|
||||
INSERT INTO `test`.`tbl`(`addtime`, `id`, `name`) VALUES ('2016-12-13 20:25:00', 3, '小孙'); #start 728 end 938 time 2016-12-13 20:28:05
|
||||
|
|
Loading…
Reference in New Issue