taosdump is a tool application that supports backing up data from a running TDengine cluster and restoring the backed up data to the same or another running TDengine cluster.
taosdump 可以用数据库、超级表或普通表作为逻辑数据单元进行备份,也可以对数据库、超级
taosdump can back up a database, a super table, or a normal table as a logical data unit or backup data records in the database, super tables, and normal tables. When using taosdump, you can specify the directory path for data backup. If you do not specify a directory, taosdump will back up the data to the current directory by default.
Suppose the specified location already has data files. In that case, taosdump will prompt the user and exit immediately to avoid data overwriting which means that the same path can only be used for one backup.
如果看到相关提示,请小心操作。
Please be careful if you see a prompt for this.
taosdump 是一个逻辑备份工具,它不应被用于备份任何原始数据、环境设置、
taosdump is a logical backup tool and should not be used to back up any raw data, environment settings,
硬件信息、服务端配置或集群的拓扑结构。taosdump 使用
Users should not use taosdump to back up raw data, environment settings, hardware information, server configuration, or cluster topology. taosdump uses [Apache AVRO](https://avro.apache.org/) as the data file format to store backup data.
-Install the taosTools official installer. Please find taosTools from [All download links](https://www.taosdata.com/all-downloads) page and download and install it.
3.back up some super or normal tables in the specified database: use `-dbname stbname1 stbname2 tbname1 tbname2 ... ` parameters. Note that the first parameter of this input sequence is the database name, and only one database is supported. The second and subsequent parameters are the names of super or normal tables in that database, separated by spaces.
4.back up the system log database: TDengine clusters usually contain a system database named `log`. The data in this database is the data that TDengine runs itself, and the taosdump will not back up the log database by default. If users need to back up the log database, users can use the `-a` or `-allow-sys` command line parameter.
5.Loose mode backup: taosdump version 1.4.1 onwards provides `-n` and `-L` parameters for backing up data without using escape characters and "loose" mode, which can reduce the number of backups if table names, column names, tag names do not use This can reduce the backup data time and backup data footprint if table names, column names, and tag names do not use `escape character`. If you are unsure about using `-n` and `-L` conditions, please use the default parameters for "strict" mode backup. See the [official documentation](/taos-sql/escape) for a description of escaped characters.
- taosdump versions after 1.4.1 provide the `-I` argument for parsing Avro file schema and data. If users specify `-s` then only taosdump will parse schema.
-Backups after taosdump 1.4.2 use the batch count specified by the `-B` parameter. The default value is 16384. If, in some environments, low network speed or disk performance causes "Error actual dump ... batch ..." can be tried by challenging the `-B` parameter to a smaller value.
Restore the data file in the specified path: use the `-i` parameter plus the path to the data file. You should not use the same directory to backup different data sets, and you should not backup the same data set multiple times in the same path. Otherwise, the backup data will cause overwriting or multiple backups.
taosdump internally uses TDengine stmt binding API for writing recovery data and currently uses 16384 as one write batch for better data recovery performance. If there are more columns in the backup data, it may cause a "WAL size exceeds limit" error. You can try to adjust to a smaller value by using the `-B` parameter.
:::
:::
## 详细命令行参数列表
## Detailed command line parameter list
以下为 taosdump 详细命令行参数列表:
The following is a detailed list of taosdump command line arguments.
The TDengine command-line application (hereafter referred to as TDengine CLI) is the cleanest and most common way for users to manipulate and interact with TDengine instances.
If executed on the TDengine server-side, there is no need for additional installation as it is already installed automatically. To run on the non-TDengine server-side, the TDengine client driver needs to be installed. For details, please refer to [connector](/reference/connector/).
## 执行
## Execution
要进入 TDengine CLI,您只要在 Linux 终端或Windos 终端执行 `taos` 即可。
To access the TDengine CLI, you can execute `taos` from a Linux terminal or Windows terminal.
TDengine will display a welcome message and version information if the connection to the service is successful. If it fails, TDengine will print an error message (see [FAQ](/train-faq/faq) to solve the problem of terminal connection failure to the server.) The TDengine CLI prompt symbols are as follows:
```cmd
```cmd
taos>
taos>
```
```
进入CLI后,你可执行各种SQL语句,包括插入、查询以及各种管理命令。
After entering the CLI, you can execute various SQL statements, including inserts, queries, and administrative commands.
## 执行 SQL 脚本
## Execute SQL scripts
在 TDengine CLI 里可以通过 `source` 命令来运行 SQL 命令脚本。
Run SQL command scripts in the TDengine CLI via the `source` command.
```sql
```sql
taos>source<filename>;
taos>source<filename>;
```
```
## 在线修改显示字符宽度
## Modify display character width online
可以在 TDengine CLI 里使用如下命令调整字符显示宽度
Users can adjust the character display width in TDengine CLI with the following command:
```sql
```sql
taos>SETMAX_BINARY_DISPLAY_WIDTH<nn>;
taos>SETMAX_BINARY_DISPLAY_WIDTH<nn>;
```
```
如显示的内容后面以...结尾时,表示该内容已被截断,可通过本命令修改显示字符宽度以显示完整的内容。
If the displayed content is followed by `...` you can use this command to change the display width to display the full content.
## 命令行参数
## Command Line Parameters
您可通过配置命令行参数来改变 TDengine CLI 的行为。以下为常用的几个命令行参数:
You can change the behavior of TDengine CLI by configuring command-line parameters. The following command-line arguments are commonly used.
-c, --config-dir: Specify the configuration file directory. The default is `/etc/taos`, and the default name of the configuration file in this directory is taos.cfg
- -C, --dump-config: 打印 -c 指定的目录中 taos.cfg 的配置参数
-C, --dump-config: Print the configuration parameters of taos.cfg in the directory specified by -c
- -d, --database=DATABASE: 指定连接到服务端时使用的数据库
-d, --database=DATABASE: Specify the database to use when connecting to the server
- -D, --directory=DIRECTORY: 导入指定路径中的 SQL 脚本文件
-D, --directory=DIRECTORY: Import the SQL script file in the specified path
- -f, --file=FILE: 以非交互模式执行 SQL 脚本文件
-f, --file=FILE: Execute the SQL script file in non-interactive mode
- -k, --check=CHECK: 指定要检查的表
-k, --check=CHECK: Specify the table to be checked
- -l, --pktlen=PKTLEN: 网络测试时使用的测试包大小
-l, --pktlen=PKTLEN: Test package size to be used for network testing
-n, --netrole=NETROLE: test scope for network connection test, default is `startup`, The value can be `client`, `server`, `rpc`, `startup`, `sync`, `speed`, or `fqdn`.
- -r, --raw-time: 将时间输出出 uint64_t
-r, --raw-time: output the time to uint64_t
- -s, --commands=COMMAND: 以非交互模式执行的 SQL 命令
-s, --commands=COMMAND: execute SQL commands in non-interactive mode
-S, --pkttype=PKTTYPE: Specify the packet type used for network testing. The default is TCP. only `netrole` can be specified as either TCP or UDP when speed is specified
- -T, --thread=THREADNUM: 以多线程模式导入数据时的线程数
-T, --thread=THREADNUM: The number of threads to import data in multi-threaded mode
- -s, --commands: 在不进入终端的情况下运行 TDengine 命令
-s, --commands: Run TDengine commands without entering the terminal
- -z, --timezone=TIMEZONE: 指定时区,默认为本地
-z, --timezone=TIMEZONE: Specify time zone. Default is local
- -V, --version: 打印出当前版本号
-V, --version: Print out the current version number
示例:
Example.
```bash
```bash
taos -h h1.taos.com -s"use db; show tables;"
taos -h h1.taos.com -s"use db; show tables;"
```
```
## TDengine CLI 小技巧
## TDengine CLI tips
-可以使用上下光标键查看历史输入的指令
-You can use the up and down cursor keys to see the history of commands entered
-Execute SQL statements in batches. You can store a series of shell commands (ending with ;, one line for each SQL statement) in a file and execute the command `source <file-name>` in the shell to execute all SQL statements in that file automatically
- _remove.sh_: script to uninstall TDengine, please execute it carefully, link to the **rmtaos** command in the /usr/bin directory. Will remove the TDengine installation directory /usr/local/taos, but will keep /etc/taos, /var/lib/taos, /var/log/taos