Using MyFlash: A MySQL Flashback Tool for Rolling Back DML Operations
This article introduces MyFlash, an open‑source MySQL flashback utility, explains its limitations, provides step‑by‑step installation commands, details the available command‑line options for specifying databases, tables, time ranges and SQL types, and demonstrates a complete rollback test case with binlog parsing and execution.
MyFlash is an open‑source MySQL flashback tool from Meituan‑Dianping that can roll back DML (INSERT, UPDATE, DELETE) operations to a specific point in time.
Limitations
Binary log format must be ROW and binlog_row_image = FULL .
Only MySQL versions 5.6 and 5.7 are supported.
Only DML operations can be rolled back.
Installation
cd /data
wget https://github.com/Meituan-Dianping/MyFlash/archive/master.zip
unzip master.zip
mv MyFlash-master MyFlash
cd MyFlash
yum install gcc glib2-devel -y
gcc -w `pkg-config --cflags --libs glib-2.0` source/binlogParseGlib.c -o binary/flashbackUsage
flashback [OPTION...]Common options:
--databaseNames : comma‑separated list of databases to roll back (default: all).
--tableNames : comma‑separated list of tables to roll back (default: all).
--start-position / --stop-position : binlog positions to define the rollback range.
--start-datetime / --stop-datetime : timestamps (format %Y-%m-%d %H:%M:%S ) to define the rollback range.
--sqlTypes : comma‑separated list of SQL types to roll back (e.g., INSERT,UPDATE,DELETE ).
--maxSplitSize : maximum size (in MB) of split files after parsing.
--binlogFileNames : comma‑separated list of binlog files to process.
--outBinlogFileNameBase : prefix for generated rollback binlog files (default: binlog_output_base.flashback ).
--logLevel : log level ( debug , warning , error ).
--include-gtids / --exclude-gtids : GTID filters for rollback.
Test Case
The article walks through a scenario where a table d1.t1 receives UPDATE and DELETE statements, shows the binlog before and after the changes, and then uses MyFlash to roll back those operations.
mysql> select * from d1.t1;
+------+
| id |
+------+
| 1 |
| 2 |
| 3 |
| 4 |
| 5 |
| 10 |
| 6 |
| 7 |
| 8 |
| 9 |
+------+Rollback command:
./binary/flashback --databaseNames="d1" --tableNames="t1" --start-datetime="2020-11-29 17:22:30" --stop-datetime="2020-11-29 17:24:30" --sqlTypes="UPDATE,DELETE" --binlogFileNames=/opt/mysql/log/binlog/3308/mysql-bin.000001 --outBinlogFileNameBase=test.sqlAfter generating the reverse binlog, the article shows how to apply it with mysqlbinlog . Because the source instance runs with GTID mode enabled, the --skip-gtids option is required to avoid the error @@SESSION.GTID_NEXT cannot be set to ANONYMOUS .
mysqlbinlog --skip-gtids test.sql.flashback | mysql -S /tmp/mysqld.sock -uroot -prootFinally, the data is verified to match the state before the UPDATE operation, confirming a successful rollback.
Reference: MyFlash GitHub README
Aikesheng Open Source Community
The Aikesheng Open Source Community provides stable, enterprise‑grade MySQL open‑source tools and services, releases a premium open‑source component each year (1024), and continuously operates and maintains them.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.