Skip to content

Commit

Permalink
forgot to add files to git. T T
Browse files Browse the repository at this point in the history
  • Loading branch information
goalzz85 committed Oct 30, 2023
1 parent 03d657c commit 8485de5
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# tidb-exporter

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.**

![tidb-exporter](assets/tidb-exporter.png)

# List Databases

Specifing only the '`-p`' parameter will list all the databases on one of the TiKV nodes.

```bash
./tidb-exporter -p /data/tikv/db
```
```
1, test
10216, user
11455, xxl_job
11506, product
11558, task
```

The first column represents the inner sequence number of the databases, which is generated within TiDB. The second column contains the database name.

# List Tables

In addition to the '`-p`' parameter, you have also set '`-d`', which will list all database tables of the specified database.

```bash
./tidb-exporter -p /data/tikv/db -d user
```
```
8980, user_avatar
11906, user_detail
```

# Export Data

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.

```bash
./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.
Binary file added assets/tidb-exporter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 8485de5

Please sign in to comment.