Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.
Original topic: TIDB 备份 BACKUP and BR 问题
【TiDB Usage Environment】Production\Test Environment\POC
【TiDB Version】6.1
【Encountered Problem】
May I ask if the community version 6.1 cannot back up the database?
mysql> backup table ‘zm’.‘db2rp’ to ‘local:///home/backup/’;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your TiDB version for the right syntax to use line 1 column 17 near "‘zm’.‘db2rp’ to 'local:///home/backup/
If using BR for backup, how to use it? When I input BR, it is not recognized. Do I need to install any plugins?
Thank you.
You have a syntax error here. There is a difference between single quotes and backticks.
The correct version is:
backup table `zm`.`db2rp` to ‘local:///home/backup/’;
The default value of tidb_distsql_scan_concurrency
is 15. You can adjust it according to your actual situation.
Replace double quotes with backticks.
Just like the experts mentioned earlier, it’s a matter of symbols.
I recommend doing it without quotes, which is simpler and more convenient.
MySQL [dd]> backup table dd.table1 to ‘local:///tmp/bacp/2’;
±--------------------±-----±-------------------±--------------------±--------------------+
| Destination | Size | BackupTS | Queue Time | Execution Time |
±--------------------±-----±-------------------±--------------------±--------------------+
| local:///tmp/bacp/2 | 0 | 434666592927219715 | 2022-07-18 01:17:43 | 2022-07-18 01:17:43 |
±--------------------±-----±-------------------±--------------------±--------------------+
1 row in set (0.03 sec)
It would be great if it could be designed to add single quotes, double quotes, or no quotes at all.
Single quote ’ and double quote " are string quotes, while backtick ` is an identifier quote. You can consider database table column names as identifiers, which is stipulated by MySQL syntax. Of course, in MySQL/TiDB, you can enable ANSI_QUOTES to use double quotes " to achieve the same effect as backticks `, but this is not a common practice. For more details, you can refer to SQL Mode | PingCAP Docs
My backup command can be used, refer to the following:
Backup database
backup database test to ‘local:///opt/backup/20210204-001’;
Incremental backup
BACKUP DATABASE test
TO ‘local:///opt/backup/20210204-002’ LAST_BACKUP = ‘2021-02-04 11:50:13’;
Try using the following command:
backup table zm
.db2rp
to ‘local:///home/backup/’;
This topic will be automatically closed 60 days after the last reply. No new replies are allowed.