Sign InTry Free

Back Up and Restore RawKV

TiKV and PD can constitute a KV database when used without TiDB, which is called RawKV. Backup & Restore (BR) supports data backup and restore for products that use RawKV. This document describes how to back up and restore RawKV.

Back up RawKV

In some scenarios, TiKV might run independently of TiDB. Given that, BR supports bypassing the TiDB layer and backing up data in TiKV.

br backup raw --pd $PD_ADDR \
    -s "local://$BACKUP_DIR" \
    --start 31 \
    --ratelimit 128 \
    --end 3130303030303030 \
    --format hex \
    --cf default

The preceding command backs up all keys between [0x31, 0x3130303030303030) in the default CF to $BACKUP_DIR.

In this command, the values of --start and --end are decoded using the format specified by --format before being sent to TiKV. Currently, the following formats are available:

  • "raw": The input string is directly encoded as a key in binary format.
  • "hex": The default encoding format. The input string is treated as a hexadecimal number.
  • "escaped": First escape (backslash) the input string, and then encode it into binary format, for example, abc\xFF\x00\r\n.

Restore RawKV

Similar to backing up RawKV, you can run the following command to restore RawKV:

br restore raw --pd $PD_ADDR \
    -s "local://$BACKUP_DIR" \
    --start 31 \
    --end 3130303030303030 \
    --ratelimit 128 \
    --format hex \
    --cf default

In this example, all the backed up keys in the range [0x31, 0x3130303030303030) are restored to the TiKV cluster. The coding formats of these keys are identical to that of keys during the backup process.

Download PDFRequest docs changes
Was this page helpful?
Open Source Ecosystem
TiDB
TiKV
TiSpark
Chaos Mesh
© 2022 PingCAP. All Rights Reserved.