Restore Data from PV

    The restore method described in this document is implemented based on CustomResourceDefinition (CRD) in TiDB Operator. For the underlying implementation, BR is used to restore the data. BR stands for Backup & Restore, which is a command-line tool for distributed backup and recovery of the TiDB cluster data.

    After backing up TiDB cluster data to PVs using BR, if you need to recover the backup SST (key-value pairs) files from PVs to a TiDB cluster, you can follow steps in this document to restore the data using BR.

    Note

    • BR is only applicable to TiDB v3.1 or later releases.

    Before restoring backup data on PVs to TiDB using BR, take the following steps to prepare the restore environment:

    1. Download .

    2. Make sure that the NFS server is accessible from your Kubernetes cluster.

    3. For a TiDB version earlier than v4.0.8, you also need to complete the following preparation steps. For TiDB v4.0.8 or a later version, skip these preparation steps.

      1. Make sure that you have the SELECT and UPDATE privileges on the mysql.tidb table of the target database so that the Restore CR can adjust the GC time before and after the restore.

    1. Create the Restore custom resource (CR), and restore the specified data to your cluster:

      When configuring , note the following:

      • The example above restores data from the local://${.spec.local.volume.nfs.path}/${.spec.local.prefix}/ directory on NFS to the demo2 TiDB cluster in the test2 namespace. For more information about PV configuration, refer to Local storage fields.

      • Some parameters in spec.br are optional, such as logLevel, statusAddr, concurrency, , checksum, timeAgo, and sendCredToTikv. For more information about .spec.br, refer to .

      • For v4.0.8 or a later version, BR can automatically adjust tikv_gc_life_time. You do not need to configure the spec.to field in the Restore CR.

      • For more information about the CR fields, refer to Restore CR fields.

    If you encounter any problem during the restore process, refer to .