Introduction:
mysqlbinlog_back.py is a tool that reads the mysqld binlog of the row format online and then generates a reverse SQL statement.
It is generally used for data recovery purposes. The so-called reverse SQL statement is if INSERT, the reverse SQL is delete.
If delete, the reverse SQL is insert, and if it is update, the reverse SQL or update, but the value of update is the original value.
This project requires installation dependencies
yum install python-pippip install pymysql
Official address: Https://github.com/58daojia-dba/mysqlbinlog_flashback
Usage Restrictions:
- 1.mysql Binlog must be in row format.
- 2. The reverse-generated table must have a primary key.
- 3. Logs must be in the master inventory
- 4. The reverse-generated MySQL data type is listed below. Types not listed are not rigorously tested and may be problematic
- 5. Types of support
Allow parsing of the field type, not inside the error will be
allow_type={"varchar": true, "char": True, "datetime": True, "date": true, "time": true, "timestamp": true, "bigint": true, "Mediumint": true, "smallint": true, "tinyint": true, "int": true, "smallint": true, "decimal": true, "float": true, "double ": True," Longtext ": True," Tinytext ": True," text ": True," Mediumtext ": true}
Tool Installation:
Installation packages can be downloaded on github
Unzip directly to enter the directory as follows:
Tool use:
# 查看下参数使用说明python mysqlbinlog_back.py --help # 回滚某个表python mysqlbinlog_back.py --host="192.168.1.60" --port=3306 --username="root" --password="yourpassword" --schema=test --tables="test_tb" -S "mysql-bin.000009"
Rollback statements are generated in the Mysqlbinlog_flashback-master/log directory when the rollback is complete
The following statements are then executed to roll back in the database
mysql -uroot -pyourpassword --default-character-set=utf8mb4 test < flashback_test_20170912_170610.sql
The "MySQL" Mysqlbinlog_flashback tool uses