title | summary |
---|---|
Use BR Command-line for Backup and Restoration |
Learn how to use the BR command line to back up and restore cluster data. |
This document describes how to back up and restore TiDB cluster data using the BR command line.
Make sure you have read BR Tool Overview, especially Usage restrictions and Some tips.
A br
command consists of sub-commands, options, and parameters.
- Sub-command: the characters without
-
or--
. - Option: the characters that start with
-
or--
. - Parameter: the characters that immediately follow behind and are passed to the sub-command or the option.
This is a complete br
command:
{{< copyable "shell-regular" >}}
`br backup full --pd "${PDIP}:2379" -s "s3://backup-data/2022-01-30/"`
Explanations for the above command are as follows:
backup
: the sub-command ofbr
.full
: the sub-command ofbackup
.-s
(or--storage
): the option that specifies the path where the backup files are stored."s3://backup-data/2022-01-30/"
: the parameter of-s
, indicating that backup data is stored to the2022-01-30/
directory in thebackup-data
bucket of Amazon S3.--pd
: the option that specifies the Placement Driver (PD) service address."${PDIP}:2379"
: the parameter of--pd
.
A br
command consists of multiple layers of sub-commands. Currently, BR has the following sub-commands:
br backup
: used to back up the data of the TiDB cluster.br restore
: used to restore the data of the TiDB cluster.
Each of the above sub-commands might still include the following sub-commands to specify the scope of an operation:
full
: used to back up or restore all the cluster data.db
: used to back up or restore the specified database of the cluster.table
: used to back up or restore a single table in the specified database of the cluster.
--pd
: used for connection, specifying the PD server address. For example,"${PDIP}:2379"
.-h
(or--help
): used to get help on all sub-commands. For example,br backup --help
.-V
(or--version
): used to check the version of BR.--ca
: specifies the path to the trusted CA certificate in the PEM format.--cert
: specifies the path to the SSL certificate in the PEM format.--key
: specifies the path to the SSL certificate key in the PEM format.--status-addr
: specifies the listening address through which BR provides statistics to Prometheus.
To back up cluster data, run the br backup
command. You can add the full
or table
sub-command to specify the scope of your backup operation: the whole cluster or a single table.
- Back up TiDB cluster snapshots
- Back up a database
- Back up a table
- Back up multiple tables with table filter
- Back Up data on Amazon S3 using BR
- Back up data on Google Cloud Storage using BR
- Back up data on Azure Blob Storage using BR
- Back up incremental data
- Encrypt data during backup
To restore cluster data, run the br restore
command. You can add the full
, db
or table
sub-command to specify the scope of your restoration: the whole cluster, a database or a single table.