TiDB uses RocksDB as default storage engine(in fact, TiKV uses it).
tidb-exporter can export data from pure RocksDB data files even when TiDB server is not running. This is very useful for exporting data in cases where TiDB is shut down for some reason and recovery is difficult.
Make sure TiDB or TiKV server is not running before using this tool.
Specifing only the '
-p' parameter will list all the databases on one of the TiKV nodes.
./tidb-exporter -p /data/tikv/db
The first column represents the inner sequence number of the databases, which is generated within TiDB. The second column contains the database name.
In addition to the '
-p' parameter, you have also set '
-d', which will list all database tables of the specified database.
./tidb-exporter -p /data/tikv/db -d user
When Specifying the '
-t' parameter to export data from a specified table, you should also specify the '-w' parameter to indicate which
Writer you want to use, although currently, only
csv is available. Finally, use the '
-e' to indicate the location to which the
Writer will write.
./tidb-exporter -p /data/tikv/db -d user -t user_avatar -w csv -e ~/user.csv
tidb-exporter exports all the data that has been stored in RocksDB, which means it will export regions even if they are not leaders in this TiKV node. If you have a cluster with three nodes, it will theoretically export all the data in the database.