## 模块 4：备份和恢复 TiDB Cloud Dedicated 集群

在本模块中，我们将了解如何备份和恢复 TiDB Cloud Dedicated。

### 步骤 1. 打开备份面板

+ 展开 `Data` 窗格，然后点击 `Backup`。

  ![80%](https://lab-static.pingcap.com/images/2025/7/24/687dfb88198979dfe5040c3c45d658782cbf79cd.png)

+ 点击右上角的 `Backup Settings`。

### 步骤 2. 查看 `Auto Backup` 选项

+ 在此页面上，您可以配置 `Auto Backup`

  ![80%](https://lab-static.pingcap.com/images/2025/7/24/b46f12a809000bbcd1ebcc53ce4d1b09bddf0588.png)

### 步骤 3. 执行手动备份

+ 在 `Backup` 页面上，点击 `Manual Backup`。

  ![80%](https://lab-static.pingcap.com/images/2025/7/31/0ad36bb503635304557dec3719fa13e86ce73cd6.png)

+ 输入 `BikeshareHistory` 作为 `Name`，然后点击 `Confirm`。

  ![80%](https://lab-static.pingcap.com/images/2025/7/25/5bd531088fee9627486bd7a0ff05454db5e04cb2.png)

+ 备份应该在 10 到 20 分钟内准备就绪。

  ![80%](https://lab-static.pingcap.com/images/2025/7/24/c7f35be2cc829b16389b733af02975048dcd9c56.png)

### 步骤 4. 恢复备份

+ 点击 `...`。

  ![80%](https://lab-static.pingcap.com/images/2025/7/24/a4c3c015fea2a53e922c10ce519667472fe3f804.png)

+ 配置恢复的集群，然后点击 `Restore`。

![80%](https://lab-static.pingcap.com/images/2025/7/24/cb5b1874788daead9f428dd8681cd243de6e82ce.png)

> [!TIP]
> 恢复后的集群配置可以与原集群不同。
> 例如，您可以调整节点数量（增加或减少节点），您还可以更改磁盘大小。

### 步骤 5. 连接到 `Cluster-Restore`

+ 点击右上角的 `Connect` 打开连接面板。
+ 选择 `Public` 作为 `Connection Type`。
+ 然后，点击 `Configure IP Access List`。
+ 选择 `Allow access from anywhere`。
+ 然后，点击 `Comfirm`。
+ 打开 [Terminal 2](ssh://monitor1-ssh#2)
+ 使用连接命令连接到 `Cluster-Restore`。

  ```bash
  mysql --comments -u 'root' -h <host_url> -P 4000 -D 'test' --ssl-mode=VERIFY_IDENTITY --ssl-ca=/home/ubuntu/ca.pem -p'<PASSWORD>'
  ```

  ```output
  ...
  Your MySQL connection id is 227
  Server version: 8.0.11-TiDB-v8.5.2 TiDB Server (Apache License 2.0) Enterprise Edition, MySQL 8.0 compatible

  Copyright (c) 2000, 2025, Oracle and/or its affiliates.

  Oracle is a registered trademark of Oracle Corporation and/or its
  affiliates. Other names may be trademarks of their respective owners.
  ...
  ```

### 步骤 6. 检查恢复的数据

  ```sql
  USE bikeshare;
  SELECT ride_id, rideable_type, started_at, ended_at FROM `trips` WHERE start_station_name='12th & U St NW' limit 3;
  ```

  ```output
  MySQL [bikeshare]> SELECT ride_id, rideable_type, started_at, ended_at FROM `trips` WHERE start_station_name='12th & U St NW' limit 3;
  +------------------+---------------+---------------------+---------------------+
  | ride_id          | rideable_type | started_at          | ended_at            |
  +------------------+---------------+---------------------+---------------------+
  | 000B23FFC23B5FC8 | classic_bike  | 2020-12-22 12:33:12 | 2020-12-22 12:41:59 |
  | 0023EE3F7FA273AA | docked_bike   | 2020-12-31 11:02:14 | 2020-12-31 12:21:51 |
  | 0025068889EA0F45 | docked_bike   | 2020-11-19 14:45:34 | 2020-11-19 14:51:37 |
  +------------------+---------------+---------------------+---------------------+
  3 rows in set (0.004 sec)
  ```

  ```sql
  exit
  ```

### 步骤 7. 删除 `Cluster-Restore`

+ 前往 `Overview`，点击 `...`，然后删除您的集群。

  ![80%](https://lab-static.pingcap.com/images/2025/7/24/a319028d778d0e722f741644e79f7e9d655ad37b.png)
