today,i'll have a test with the open source tool mysqlbinlog_flashback which is released by 58daojia,here's the github address:https://github.com/58daojia-dba/mysqlbinlog_flashback  this tool is similar with the binlog2sql which is also coded by python.let's download and unzip the tool:

 

 [root@zlm1 :: /vagrant]
#cd mysqlbinlog_flashback-master [root@zlm1 :: /vagrant/mysqlbinlog_flashback-master]
#ls -l
total
-rwxrwxrwx vagrant vagrant Dec binlogstream.py.diff
-rwxrwxrwx vagrant vagrant Dec CHANGELOG.txt
-rwxrwxrwx vagrant vagrant Dec constant.py
-rwxrwxrwx vagrant vagrant Dec flashback.py
-rwxrwxrwx vagrant vagrant Dec func.py
drwxrwxrwx vagrant vagrant Jun : internal
-rwxrwxrwx vagrant vagrant Dec joint_sql.py
-rwxrwxrwx vagrant vagrant Dec LICENSE
drwxrwxrwx vagrant vagrant Jun : log
-rwxrwxrwx vagrant vagrant Dec mysqlbinlog_back.py
-rwxrwxrwx vagrant vagrant Dec mysql_table.py
drwxrwxrwx vagrant vagrant Jun : pymysqlreplication
-rwxrwxrwx vagrant vagrant Dec README.md
drwxrwxrwx vagrant vagrant Jun : test [root@zlm1 :: /vagrant/mysqlbinlog_flashback-master]
#python mysqlbinlog_back.py --help
Traceback (most recent call last):
File "mysqlbinlog_back.py", line , in <module>
from flashback import Parameter,deal_all_event,generate_create_table,convert_datetime_to_timestamp
File "/vagrant/mysqlbinlog_flashback-master/flashback.py", line , in <module>
from pymysqlreplication import BinLogStreamReader
File "/vagrant/mysqlbinlog_flashback-master/pymysqlreplication/__init__.py", line , in <module>
from .binlogstream import BinLogStreamReader
File "/vagrant/mysqlbinlog_flashback-master/pymysqlreplication/binlogstream.py", line , in <module>
import pymysql
ImportError: No module named pymysql [root@zlm1 :: /vagrant/mysqlbinlog_flashback-master]
#python --version
Python 2.7. [root@zlm1 :: /vagrant/mysqlbinlog_flashback-master]
#

    the tool need python 2.6,mine is 2.7.5,i'll go to the python official website to download it,Python 2.6.9 is the final version of 2.6.x since Oct.29 2013.here's the address:https://www.python.org/download/releases/2.6.9/,below is the directory structure in Python 2.6.9:

 [root@zlm1 :: ~/Python-2.6.]
#ls -l
total
-rwxr-xr-x root root Oct configure
-rw-r--r-- root root Oct configure.in
drwxrwxr-x root root Oct Demo
drwxrwxr-x root root Oct Doc
drwxrwxr-x root root Oct Grammar
drwxrwxr-x root root Oct Include
-rwxr-xr-x root root Oct install-sh
drwxrwxr-x root root Oct Lib
-rw-r--r-- root root Oct LICENSE
drwxrwxr-x root root Oct Mac
-rw-r--r-- root root Oct Makefile.pre.in
drwxrwxr-x root root Oct Misc
drwxrwxr-x root root Oct Modules
drwxrwxr-x root root Oct Objects
drwxrwxr-x root root Oct Parser
drwxrwxr-x root root Oct PC
drwxrwxr-x root root Oct PCbuild
-rw-r--r-- root root Oct pyconfig.h.in
drwxrwxr-x root root Oct Python
-rw-r--r-- root root Oct README
drwxrwxr-x root root Oct RISCOS
-rw-r--r-- root root Oct setup.py
drwxrwxr-x root root Oct Tools [root@zlm1 :: ~/Python-2.6.]
#./configure && make && make install
... -- Omitted
[root@zlm1 :: ~/Python-2.6.]
#python --version
Python 2.6. [root@zlm1 :: ~/Python-2.6.]
#[root@zlm1 :: ~/mysqlbinlog_flashback-master]
#pwd
/root/mysqlbinlog_flashback-master [root@zlm1 :: ~/mysqlbinlog_flashback-master]
#python mysqlbinlog_back.py --help
Traceback (most recent call last):
File "mysqlbinlog_back.py", line , in <module>
from flashback import Parameter,deal_all_event,generate_create_table,convert_datetime_to_timestamp
File "/root/mysqlbinlog_flashback-master/flashback.py", line , in <module>
from pymysqlreplication import BinLogStreamReader
File "/root/mysqlbinlog_flashback-master/pymysqlreplication/__init__.py", line , in <module>
from .binlogstream import BinLogStreamReader
File "/root/mysqlbinlog_flashback-master/pymysqlreplication/binlogstream.py", line , in <module>
import pymysql
ImportError: No module named pymysql [root@zlm1 :: ~/mysqlbinlog_flashback-master]
#

 it still appear the identical issue,what's wrong?once more i check the readme.md it says besides the python version,"pymysql" module is also necessary.

 [root@zlm1 :: ~/pip-10.0.]
#pip install pymysql
Traceback (most recent call last):
File "/usr/bin/pip", line , in <module>
from pkg_resources import load_entry_point
ImportError: No module named pkg_resources [root@zlm1 :: ~/pip-10.0.]
#
 [root@zlm1 :: ~/PyMySQL-0.8.]
#ls -l
total
-rw-r--r-- games May : CHANGELOG
-rw-r--r-- games May example.py
-rw-r--r-- games Nov LICENSE
-rw-r--r-- games Jan MANIFEST.in
-rw-r--r-- games May : PKG-INFO
drwxr-xr-x games May : pymysql
drwxr-xr-x games May : PyMySQL.egg-info
-rw-r--r-- games May : README.rst
-rwxr-xr-x games Aug runtests.py
-rw-r--r-- games May : setup.cfg
-rwxr-xr-x games May : setup.py
-rw-r--r-- games Jan tox.ini [root@zlm1 :: ~/PyMySQL-0.8.]
#python setup.py install
Traceback (most recent call last):
File "setup.py", line , in <module>
from setuptools import setup, find_packages
ImportError: No module named setuptools [root@zlm1 :: ~/PyMySQL-0.8.]
#chown root.root -R * [root@zlm1 :: ~/PyMySQL-0.8.]
#ls -l
total
-rw-r--r-- root root May : CHANGELOG
-rw-r--r-- root root May example.py
-rw-r--r-- root root Nov LICENSE
-rw-r--r-- root root Jan MANIFEST.in
-rw-r--r-- root root May : PKG-INFO
drwxr-xr-x root root May : pymysql
drwxr-xr-x root root May : PyMySQL.egg-info
-rw-r--r-- root root May : README.rst
-rwxr-xr-x root root Aug runtests.py
-rw-r--r-- root root May : setup.cfg
-rwxr-xr-x root root May : setup.py
-rw-r--r-- root root Jan tox.ini [root@zlm1 :: ~/PyMySQL-0.8.]
#python setup.py install
Traceback (most recent call last):
File "setup.py", line , in <module>
from setuptools import setup, find_packages
ImportError: No module named setuptools -- It seems another module name "setuptools" is needed. [root@zlm1 :: ~/setuptools-39.2.]
#ls -l
total
-rwxrwxrwx root root May : bootstrap.py
-rwxrwxrwx root root May : CHANGES.rst
-rwxrwxrwx root root May : conftest.py
drwxrwxrwx root root Jun : docs
-rwxrwxrwx root root May : easy_install.py
-rwxrwxrwx root root May : launcher.c
-rwxrwxrwx root root May : LICENSE
-rwxrwxrwx root root May : MANIFEST.in
-rwxrwxrwx root root May : msvc-build-launcher.cmd
-rwxrwxrwx root root May : pavement.py
-rwxrwxrwx root root May : PKG-INFO
drwxrwxrwx root root Jun : pkg_resources
-rwxrwxrwx root root May : pytest.ini
-rwxrwxrwx root root May : README.rst
-rwxrwxrwx root root May : setup.cfg
-rwxrwxrwx root root May : setup.py
drwxrwxrwx root root Jun : setuptools
drwxrwxrwx root root Jun : setuptools.egg-info
drwxrwxrwx root root Jun : tests
-rwxrwxrwx root root May : towncrier_template.rst
-rwxrwxrwx root root May : tox.ini [root@zlm1 :: ~/setuptools-39.2.]
#python setup.py install
running install
running bdist_egg
running egg_info
writing requirements to setuptools.egg-info/requires.txt
writing setuptools.egg-info/PKG-INFO
writing top-level names to setuptools.egg-info/top_level.txt
writing dependency_links to setuptools.egg-info/dependency_links.txt
writing entry points to setuptools.egg-info/entry_points.txt
reading manifest file 'setuptools.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'setuptools.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
creating build
creating build/lib
... -- Omitted. root@zlm1 :: ~/PyMySQL-0.8.]
#python setup.py install
/usr/lib64/python2./distutils/dist.py:: UserWarning: Unknown distribution option: 'project_urls'
warnings.warn(msg)
running install
running bdist_egg
running egg_info
writing PyMySQL.egg-info/PKG-INFO
writing top-level names to PyMySQL.egg-info/top_level.txt
writing dependency_links to PyMySQL.egg-info/dependency_links.txt
reading manifest file 'PyMySQL.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'PyMySQL.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
creating build
creating build/lib
creating build/lib/pymysql
... -- Omitted. --Finally the PyMySQL was installed successfully.
 [root@zlm1 :: ~/mysqlbinlog_flashback-master]
#python mysqlbinlog_back.py --help
===log will also write to .//mysqlbinlog_flashback.log===
Usage: python mysqlbinlog_back.py [options]
sample1:python mysqlbinlog_back.py --host="127.0.0.1" --username="root" --port= --password="" --schema=test --table="test5"
sample2:python mysqlbinlog_back.py --host="127.0.0.1" --username="root" --port= --password="" --schema=test --table="test5,test6" --binlog_end_time="2016-11-05 11:27:13" --binlog_start_file_name="mysql-bin.000024" --binlog_start_file_position= --binlog_start_time="2016-11-04 11:27:13" --skip_delete --skip_insert --add_schema_name
sample3:python mysqlbinlog_back.py --host="127.0.0.1" --username="root" --port= --password="" --schema=test --table="test5,test6" --binlog_start_file_name="mysql-bin.000022" Options:
-h, --help show this help message and exit
-H HOST, --host=HOST mandatory,mysql hostname
-P PORT, --port=PORT mysql port,default
-u USERNAME, --username=USERNAME
mandatory,username
-p PASSWORD, --password=PASSWORD
password
-s SCHEMA, --schema=SCHEMA
mandatory,mysql schema
-t TABLES, --tables=TABLES
mandatory,mysql tables,suport multiple tables,use
comma as separator
-N BINLOG_END_TIME, --binlog_end_time=BINLOG_END_TIME
binlog end time,format yyyy-mm-dd hh24:mi:ss,default
is current time
-S BINLOG_START_FILE_NAME, --binlog_start_file_name=BINLOG_START_FILE_NAME
binlog start file name,default is current logfile of
db
-L BINLOG_START_FILE_POSITION, --binlog_start_file_position=BINLOG_START_FILE_POSITION
binlog start file name
-E BINLOG_START_TIME, --binlog_start_time=BINLOG_START_TIME
binlog start time,format yyyy-mm-dd hh24:mi:ss
-l OUTPUT_FILE_PATH, --output_file_path=OUTPUT_FILE_PATH
file path that sql generated,,default ./log
-I, --skip_insert skip insert(WriteRowsEvent) event
-U, --skip_update skip update(UpdateRowsEvent) event
-D, --skip_delete skip delete(DeleteRowsEvent) event
-a, --add_schema_name
add schema name for flashback sql
-v, --version version info

    okay,now the tool mysqlbinlog_flashback can te used normally,let's begin our data-loss flashback test:

 root@localhost:mysql3306.sock [zlm]05:39:39>create table test(
-> id bigint not null auto_increment,
-> name varchar(20) not null default '',
-> primary key(id)
-> ) engine=innodb default charset=utf8mb4;
Query OK, 0 rows affected (0.05 sec) root@localhost:mysql3306.sock [zlm]05:39:45>delimiter //
root@localhost:mysql3306.sock [zlm]05:39:51>create procedure pro_insert()
-> begin
-> declare id int;
-> set id = 100000;
-> while id>0 do
-> insert into test(name) values ('aaron8219');
-> set id=id-1;
-> end while;
-> end //
Query OK, 0 rows affected (0.05 sec) root@localhost:mysql3306.sock [zlm]05:39:51>delimiter ;
root@localhost:mysql3306.sock [zlm]05:39:53>call pro_insert();
Query OK, 1 row affected (8.87 sec) root@localhost:mysql3306.sock [zlm]05:40:40>select count(*) from test;
+----------+
| count(*) |
+----------+
| 100000 |
+----------+
1 row in set (0.03 sec) root@localhost:mysql3306.sock [zlm]05:41:02>flush logs;
Query OK, 0 rows affected (0.12 sec) root@localhost:mysql3306.sock [zlm]05:42:03>show binary log;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'log' at line 1
root@localhost:mysql3306.sock [zlm]05:42:10>show binary logs;
+------------------+-----------+
| Log_name | File_size |
+------------------+-----------+
| mysql-bin.000016 | 680 |
| mysql-bin.000017 | 268435617 |
| mysql-bin.000018 | 72724171 |
| mysql-bin.000019 | 241 |
| mysql-bin.000020 | 11019314 |
| mysql-bin.000021 | 241 |
| mysql-bin.000022 | 1305983 |
| mysql-bin.000023 | 268435590 |
| mysql-bin.000024 | 9566499 |
| mysql-bin.000025 | 19081875 |
| mysql-bin.000026 | 27801367 |
| mysql-bin.000027 | 1908620 |
| mysql-bin.000028 | 1908617 |
| mysql-bin.000029 | 8337364 |
| mysql-bin.000030 | 83100241 |
| mysql-bin.000031 | 3214613 |
| mysql-bin.000032 | 241 |
| mysql-bin.000033 | 217 |
| mysql-bin.000034 | 217 |
| mysql-bin.000035 | 217 |
| mysql-bin.000036 | 27000879 |
| mysql-bin.000037 | 194 |
+------------------+-----------+
22 rows in set (0.00 sec) root@localhost:mysql3306.sock [zlm]05:42:14>update test set name='zlm';
Query OK, 100000 rows affected (1.83 sec)
Rows matched: 100000 Changed: 100000 Warnings: 0 root@localhost:mysql3306.sock [zlm]05:42:38>select * from test limit 1,5;
+----+------+
| id | name |
+----+------+
| 2 | zlm |
| 3 | zlm |
| 4 | zlm |
| 5 | zlm |
| 6 | zlm |
+----+------+
5 rows in set (0.00 sec) root@localhost:mysql3306.sock [zlm]05:43:02>show binary logs;
+------------------+-----------+
| Log_name | File_size |
+------------------+-----------+
| mysql-bin.000016 | 680 |
| mysql-bin.000017 | 268435617 |
| mysql-bin.000018 | 72724171 |
| mysql-bin.000019 | 241 |
| mysql-bin.000020 | 11019314 |
| mysql-bin.000021 | 241 |
| mysql-bin.000022 | 1305983 |
| mysql-bin.000023 | 268435590 |
| mysql-bin.000024 | 9566499 |
| mysql-bin.000025 | 19081875 |
| mysql-bin.000026 | 27801367 |
| mysql-bin.000027 | 1908620 |
| mysql-bin.000028 | 1908617 |
| mysql-bin.000029 | 8337364 |
| mysql-bin.000030 | 83100241 |
| mysql-bin.000031 | 3214613 |
| mysql-bin.000032 | 241 |
| mysql-bin.000033 | 217 |
| mysql-bin.000034 | 217 |
| mysql-bin.000035 | 217 |
| mysql-bin.000036 | 27000879 |
| mysql-bin.000037 | 3214558 |
+------------------+-----------+
22 rows in set (0.00 sec) root@localhost:mysql3306.sock [zlm]05:43:22>

    obviously,the lost data should be contained in "mysql-bin.000037",let's have a try by using mysqlbinlog_flash to get back the data,first of all,let's see what's in the binary log "mysql-bin.000037":

 [root@zlm1 :: /data/mysql/mysql3306/logs]
#mysqlbinlog -vv --base64-output=decode-rows mysql-bin. | sed -n '1,50p'
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
# at
# :: server id end_log_pos CRC32 0xf0e90436 Start: binlog v , server v 5.7.-log created ::
# Warning: this binlog is either in use or was not closed properly.
# at
# :: server id end_log_pos CRC32 0xb6bac207 Previous-GTIDs
# 2a4b3562-2ab6-11e8-be7a-080027de0e0e:-
# at
# :: server id end_log_pos CRC32 0x67866ae9 GTID last_committed= sequence_number= rbr_only=yes
/*!50718 SET TRANSACTION ISOLATION LEVEL READ COMMITTED*//*!*/;
SET @@SESSION.GTID_NEXT= '2a4b3562-2ab6-11e8-be7a-080027de0e0e:2600052'/*!*/;
# at
# :: server id end_log_pos CRC32 0xd92b1815 Query thread_id= exec_time= error_code=
SET TIMESTAMP=/*!*/;
SET @@session.pseudo_thread_id=/*!*/;
SET @@session.foreign_key_checks=, @@session.sql_auto_is_null=, @@session.unique_checks=, @@session.autocommit=/*!*/;
SET @@session.sql_mode=/*!*/;
SET @@session.auto_increment_increment=, @@session.auto_increment_offset=/*!*/;
/*!\C utf8 *//*!*/;
SET @@session.character_set_client=,@@session.collation_connection=,@@session.collation_server=/*!*/;
SET @@session.lc_time_names=/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
BEGIN
/*!*/;
# at
# :: server id end_log_pos CRC32 0xcfa8815d Table_map: `zlm`.`test` mapped to number -- The Table_map event from position .
# at
# :: server id end_log_pos CRC32 0xadcde7b6 Update_rows: table id -- The Update_rows event from postion .
# at
# :: server id end_log_pos CRC32 0xee29017d Update_rows: table id
# at
# :: server id end_log_pos CRC32 0x6306a3c2 Update_rows: table id
# at
# :: server id end_log_pos CRC32 0x69ca971f Update_rows: table id
# at
# :: server id end_log_pos CRC32 0xb99e0b43 Update_rows: table id
# at
# :: server id end_log_pos CRC32 0xe8438e0a Update_rows: table id
# at
# :: server id end_log_pos CRC32 0x2a83a31d Update_rows: table id
# at
# :: server id end_log_pos CRC32 0xbcb85d9c Update_rows: table id
# at
# :: server id end_log_pos CRC32 0xfd385e6b Update_rows: table id
# at
# :: server id end_log_pos CRC32 0x5dd0ec46 Update_rows: table id
# at
# :: server id end_log_pos CRC32 0x14c028cb Update_rows: table id
-- Omitted
 [root@zlm1 :: ~/mysqlbinlog_flashback-master]
#pwd
/root/mysqlbinlog_flashback-master [root@zlm1 :: ~/mysqlbinlog_flashback-master]
#python mysqlbinlog_back.py --host="127.0.0.1" --username="root" --port= --password="Passw0rd" --schema=zlm --table="test" --add_schema_name
===log will also write to .//mysqlbinlog_flashback.log===
parameter={'start_binlog_file': u'mysql-bin.000037', 'stream': None, 'keep_data': True, 'file': {'data_create': None, 'flashback': None, 'data': None}, 'add_schema_name': True, 'start_time': None, 'keep_current_data': False, 'start_to_timestamp': None, 'mysql_setting': {'passwd': 'Passw0rd', 'host': '127.0.0.1', 'charset': 'utf8', 'port': , 'user': 'root'}, 'table_name': 'test', 'skip_delete': False, 'schema': 'zlm', 'stat': {'flash_sql': {}}, 'table_name_array': ['test'], 'one_binlog_file': False, 'output_file_path': './log', 'start_position': , 'skip_update': False, 'dump_event': False, 'end_to_timestamp': 1528473771.0, 'skip_insert': False, 'schema_array': ['zlm']}
===statistics===
scan events
{'flash_sql': {u'zlm': {u'test': {'insert': , 'update': , 'delete': }}}} [root@zlm1 :: ~/mysqlbinlog_flashback-master]
#ls -l
total
-rwxrwxrwx root root Dec binlogstream.py.diff
-rwxrwxrwx root root Dec CHANGELOG.txt
-rwxrwxrwx root root Dec constant.py
-rw-r--r-- root root Jun : constant.pyc
-rwxrwxrwx root root Dec flashback.py
-rwxrwxrwx root root Jun : flashback.pyc
-rwxrwxrwx root root Dec func.py
-rwxrwxrwx root root Jun : func.pyc
drwxrwxrwx root root Jun : internal
-rwxrwxrwx root root Dec joint_sql.py
-rw-r--r-- root root Jun : joint_sql.pyc
-rwxrwxrwx root root Dec LICENSE
drwxrwxrwx root root Jun : log -- If you don't sepcify the "OUTPUT_FILE_PATH",this directory is default value.
-rwxrwxrwx root root Dec mysqlbinlog_back.py
-rw-r--r-- root root Jun : mysqlbinlog_flashback.log
-rwxrwxrwx root root Dec mysql_table.py
-rw-r--r-- root root Jun : mysql_table.pyc
drwxrwxrwx root root Jun : pymysqlreplication
-rwxrwxrwx root root Dec README.md
drwxrwxrwx root root Jun : test [root@zlm1 :: ~/mysqlbinlog_flashback-master]
#cd log [root@zlm1 :: ~/mysqlbinlog_flashback-master/log]
#ls -l
total
-rw-r--r-- root root Jun : flashback_zlm_20180608_180251.sql -- This file contains the real records to flashback.
-rw-r--r-- root root Jun : save_data_create_table_zlm_20180608_180251.sql -- This file contains the structure of intermediate table.
-rw-r--r-- root root Jun : save_data_dml_zlm_20180608_180251.sql -- This file contains the records which will be inserted into the intermediate table which called "_test_keep_data_"(here,"test" is the real table name which you want to flashback data)
-rwxrwxrwx root root Dec test.txt [root@zlm1 :: ~/mysqlbinlog_flashback-master/log]
#cat save_data_create_table_zlm_20180608_180251.sql
CREATE TABLE `_test_keep_data_` (op varchar(),op_datetime datetime,bfr_id bigint(),bfr_name varchar(),aft_id bigint(),aft_name varchar()) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; [root@zlm1 :: ~/mysqlbinlog_flashback-master/log]
#cat save_data_dml_zlm_20180608_180251.sql | tail -
insert into `_test_keep_data_`(`op_datetime`,`bfr_name`,`aft_id`,`aft_name`,`bfr_id`,`op`) values('2018-06-08 17:42:36','aaron8219',,'zlm',,'update');
insert into `_test_keep_data_`(`op_datetime`,`bfr_name`,`aft_id`,`aft_name`,`bfr_id`,`op`) values('2018-06-08 17:42:36','aaron8219',,'zlm',,'update');
insert into `_test_keep_data_`(`op_datetime`,`bfr_name`,`aft_id`,`aft_name`,`bfr_id`,`op`) values('2018-06-08 17:42:36','aaron8219',,'zlm',,'update');
insert into `_test_keep_data_`(`op_datetime`,`bfr_name`,`aft_id`,`aft_name`,`bfr_id`,`op`) values('2018-06-08 17:42:36','aaron8219',,'zlm',,'update');
insert into `_test_keep_data_`(`op_datetime`,`bfr_name`,`aft_id`,`aft_name`,`bfr_id`,`op`) values('2018-06-08 17:42:36','aaron8219',,'zlm',,'update');
insert into `_test_keep_data_`(`op_datetime`,`bfr_name`,`aft_id`,`aft_name`,`bfr_id`,`op`) values('2018-06-08 17:42:36','aaron8219',,'zlm',,'update');
insert into `_test_keep_data_`(`op_datetime`,`bfr_name`,`aft_id`,`aft_name`,`bfr_id`,`op`) values('2018-06-08 17:42:36','aaron8219',,'zlm',,'update');
insert into `_test_keep_data_`(`op_datetime`,`bfr_name`,`aft_id`,`aft_name`,`bfr_id`,`op`) values('2018-06-08 17:42:36','aaron8219',,'zlm',,'update');
insert into `_test_keep_data_`(`op_datetime`,`bfr_name`,`aft_id`,`aft_name`,`bfr_id`,`op`) values('2018-06-08 17:42:36','aaron8219',,'zlm',,'update');
insert into `_test_keep_data_`(`op_datetime`,`bfr_name`,`aft_id`,`aft_name`,`bfr_id`,`op`) values('2018-06-08 17:42:36','aaron8219',,'zlm',,'update'); [root@zlm1 :: ~/mysqlbinlog_flashback-master/log]
#cat flashback_zlm_20180608_180251.sql | tail -
update `zlm`.`test` set`id`=,`name`='aaron8219' where `id`=;
update `zlm`.`test` set`id`=,`name`='aaron8219' where `id`=;
update `zlm`.`test` set`id`=,`name`='aaron8219' where `id`=;
update `zlm`.`test` set`id`=,`name`='aaron8219' where `id`=;
update `zlm`.`test` set`id`=,`name`='aaron8219' where `id`=;
update `zlm`.`test` set`id`=,`name`='aaron8219' where `id`=;
update `zlm`.`test` set`id`=,`name`='aaron8219' where `id`=;
update `zlm`.`test` set`id`=,`name`='aaron8219' where `id`=;
update `zlm`.`test` set`id`=,`name`='aaron8219' where `id`=;
update `zlm`.`test` set`id`=,`name`='aaron8219' where `id`=; [root@zlm1 :: ~/mysqlbinlog_flashback-master/log]
#

    since we've got the sql file which can flashback our lost data,let's have a try:

 [root@zlm1 18:08:50 ~/mysqlbinlog_flashback-master/log]
#mysql --default-character-set=utf8mb4 < flashback_zlm_20180608_180251.sql [root@zlm1 18:19:59 ~/mysqlbinlog_flashback-master/log]
#mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 5.7.21-log MySQL Community Server (GPL) Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. root@localhost:mysql3306.sock [(none)]06:20:09>use zlm;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A Database changed
root@localhost:mysql3306.sock [zlm]06:20:12>select count(*) from test where name='zlm';
+----------+
| count(*) |
+----------+
| 0 |
+----------+
1 row in set (0.03 sec) root@localhost:mysql3306.sock [zlm]06:20:49>select count(*) from test where name='aaron8219';
+----------+
| count(*) |
+----------+
| 100000 |
+----------+
1 row in set (0.03 sec) root@localhost:mysql3306.sock [zlm]06:20:55>
    finally,the lost data come back again,all the column of "name" of the 100000 rows have been changed from "zlm" to "aaron8219",the test finished successfully.
 
Summary:
  • mysqlbinlog_flashback is similar with the binglog2sql which also depend on python 2.6(maybe above is also feasible),you must install several python module such as PyMySQL,setuptools to ensure the tool can work normally.
  • mysqlbinlog_flashback is surely non-offline tool when parsing the needed binary logs which is the same as MyFlash,binlog2sql.
  • mysqlbinlog_flashback works effectively,10w rows of records can be flashback in a rather short time.
  • what i most favorate point is that the output file is extraordinarily unambiguous,you can clearly see what it will really do by these sql files(check them first then flashback).
  • contrast the tool with MyFlash & binlog2sql,mysqlbinlog_flashback is the most convenient tool to flashback lost data.the other two tools are difficult to dignose when exception occurs.they seem like black boxes i'm afraid.

利用mysqlbinlog_flashback闪回丢失数据的更多相关文章

  1. 利用binlog2sql闪回丢失数据

        today,i'll using the open source tool named "binlog2sql" which is release by danfengch ...

  2. 利用MyFlash闪回丢失数据(续)

          last night,i've tested flashback by MyFlash tool,but failed,now let's do some other test with ...

  3. 利用MyFlash闪回丢失数据

          MyFlash is an open source tool released by Meituan-Dianping which can be used to flashback MyS ...

  4. oracle_利用闪回功能恢复数据

    方便起见一般:执行如下即可不用往下看: ① 启用行移动功能 alter table tbl_a enable row movement; ② 闪回表数据到某个时间点 flashback table t ...

  5. Oracle 闪回 找回数据的实现方法

    Oracle 闪回 找回数据的实现方法 闪回技术是Oracle强大数据库备份恢复机制的一部分,在数据库发生逻辑错误的时候,闪回技术能提供快速且最小损失的恢复.这篇文章主要介绍了Oracle 闪回 找回 ...

  6. Oracle闪回技术之一Oracle 11g 利用FlashTable (闪回表)恢复(用delete)误删的数据

    闪回表,实际上就是将表中的数据快速恢复到过去的一个时间点或者系统改变号SCN上.实现表的闪回,需要用到撤销表空间相关的UNDO信息,通过SHOW PARAMETER UNDO命令就可以了解这些信息.用 ...

  7. Flashback Version Query、Flashback Transaction Query快速闪回细粒度数据

    Flashback Version Query 闪回版本查询 使用Flashback Version Query  返回在指定时间间隔或SCN间隔内的所有版本,一次commit命令就会创建一个版本. ...

  8. Oracle 闪回 找回数据

    使用闪回技术,实现基于磁盘上闪回恢复区的自动备份与还原. 一.恢复表对象 1.创建学生表 create table STUDENT ( idno INTEGER, name VARCHAR2(30), ...

  9. oracle flashback data archive闪回数据归档天坑之XID重用导致闪回查询数据重复

    我们有个系统使用了Oracle flashback data archive闪回数据归档特性来作为基于时间点的恢复机制,在频繁插入.更新期间发现SYS_FBA_HIST_NNNN表中的XID被两个事务 ...

随机推荐

  1. According to TLD, tag fmt:formatDate must be empty, but is not 问题的解决

    在执行jsp格式化后报错,检查下代码,发现变成如下的样式: <fmt:formatDate value="${cur.sa_date}" pattern="yyyy ...

  2. androidUI异步消息

    private Handler handler = new Handler(){ public void handleMessage(android.os.Message msg) { switch ...

  3. C++ 11: function & bind 使用示例

    #include <functional> #include <iostream> struct Foo { Foo(int num) : num_(num) {} void ...

  4. SQL点点滴滴_修改数据库的兼容级别

    语法 ALTER DATABASE database_name SET COMPATIBILITY_LEVEL = { 80 | 90 | 100 } 参数 database_name 要修改的数据库 ...

  5. Oracle物化视图详解

    现实工作中会有多个数据源同步到一个数据库完成数据分析的场景,这些数据可以不是实时同步的,我们一般通过定时任务抽取数据到统计分析库给应用使用. 一般的同步方式可以通过时间戳做全量和增量数据同步(存在原数 ...

  6. Web API 2 入门——Web API 2(C#)入门(谷歌翻译)

    ASP.NET Web API 2(C#)入门 在这篇文章中 本教程中使用的软件版本 创建一个Web API项目 添加模型 添加控制器 使用Javascript和jQuery调用Web API 运行应 ...

  7. Oracle修改表名的几种方式

    因为原来所在表不想被删除,但又需要新建立一个相同表名的表,故先把原来的表的表名更改为另一个临时表名. 查看当前用户下所有的表  select tname from tab where tabtype= ...

  8. Simotion 绝对值编码器使用外部开关回零

    问题来源: 西门子的1FK7二代电机,目前已经没有增量编码器.标准的编码器选项是单圈绝对值,或多圈绝对值. 在某些应用中,如印刷机的版辊.模切轴.飞剪电机等,需要使用外部开关来回零.下文描述了使用外部 ...

  9. C++ 的编译过程

    Recall that g++ is not actually the C++ compiler – it is a driver program that hides a lot of the co ...

  10. Intellij IDEA设置注释作者名字

    方法一:File >> Settings >> Editor >>Code Style >> File and Code Templates>&g ...