row模式下提取binlog中DML的回滚sql

原文: http://www.oschina.net/code/snippet_617180_34028
binlog-rollback.zip

如使用过程中有任何问题,欢迎留言,谢谢!

--help # OUT : print help info       shell> perl binlog-rollback.pl -f 'mysql-bin.000001' -o '/tmp/t.sql' -u 'user' -p 'pwd' -d 'db1,db2' -T 'tb1,tb2'
Command line options :
?, --help # OUT : print help info   
-f, --srcfile # IN  : binlog file. [required]
-o, --outfile # OUT : output sql file. [required]
-h, --host # IN  : host. default '127.0.0.1'
-u, --user # IN  : user. [required]
-p, --password # IN  : password. [required] 
-P, --port # IN  : port. default '3306'
--start-position # IN  : start position
--stop-position # IN  : stop position
-d, --database # IN  : database, split comma
-T, --table # IN  : table, split comma. [must] set -d
-i, --ignore # IN  : ignore binlog check contain DDL(CREATE|ALTER|DROP|RENAME)
--debug # IN  :  print debug information


Sample :
   shell> perl binlog-rollback.pl -f 'mysql-bin.000001' -o '/tmp/t.sql' -u 'user' -p 'pwd' 
   shell> perl binlog-rollback.pl -f 'mysql-bin.000001' -o '/tmp/t.sql' -u 'user' -p 'pwd' -i
   shell> perl binlog-rollback.pl -f 'mysql-bin.000001' -o '/tmp/t.sql' -u 'user' -p 'pwd' --debug
   shell> perl binlog-rollback.pl -f 'mysql-bin.000001' -o '/tmp/t.sql' -h '192.168.1.2' -u 'user' -p 'pwd' -P 3307
   shell> perl binlog-rollback.pl -f 'mysql-bin.000001' -o '/tmp/t.sql' -u 'user' -p 'pwd' --start-position=107
   shell> perl binlog-rollback.pl -f 'mysql-bin.000001' -o '/tmp/t.sql' -u 'user' -p 'pwd' --start-position=107 --stop-position=10000
   shell> perl binlog-rollback.pl -f 'mysql-bin.000001' -o '/tmp/t.sql' -u 'user' -p 'pwd' -d 'db1,db2'
   shell> perl binlog-rollback.pl -f 'mysql-bin.0000*' -o '/tmp/t.sql' -u 'user' -p 'pwd' -d 'db1,db2' -T 'tb1,tb2'
请使用浏览器的分享功能分享到微信等