## モジュール 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)

+ `Name` として `BikeshareHistory` を入力し、`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` をクリックして接続パネルを開きます。
+ `Connection Type` として `Public` を選択します。
+ 次に、`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)
