

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 從 Amazon RDS 的複寫備份還原至指定的時間
<a name="AutomatedBackups.PiTR"></a>

您可以使用 Amazon RDS 主控台從複寫備份將資料庫執行個體還原至特定的時間點。您也可以使用 `restore-db-instance-to-point-in-time` AWS CLI 命令或 `RestoreDBInstanceToPointInTime` RDS API 操作。

如需有關 point-in-time 恢復 (PITR) 的一般資訊，請參閱 [將 Amazon RDS 的資料庫執行個體還原至指定時間](USER_PIT.md)。

**注意**  
跨 AWS 區域 複寫自動備份時，請注意下列資料庫引擎限制：  
在 RDS for SQL Server 上，不會複製選項群組。
在 RDS for Oracle 上，不會複製下列選項：`NATIVE_NETWORK_ENCRYPTION`、`OEM`、`OEM_AGENT` 和 `SSL`。
如果您已將自訂選項群組與 資料庫執行個體相關聯，則可以在目的地區域中重新建立該選項群組。然後還原目的地區域中的資料庫執行個體，並將自訂選項群組與其關聯。如需詳細資訊，請參閱 [使用選項群組](USER_WorkingWithOptionGroups.md)。

## 主控台
<a name="AutomatedBackups.PiTR.Console"></a>

**從複寫備份將資料庫執行個體還原至指定的時間**

1. 登入 AWS 管理主控台，開啟位於 [https://console.aws.amazon.com/rds/](https://console.aws.amazon.com/rds/) 的 Amazon RDS 主控台。

1. 從區域選取器中選擇目的地區域 (將備份複製到的位置)。

1. 在導覽窗格中，選擇 **Automated backups** (自動備份)。

1. 在 **Replicated backups (複寫備份)** 標籤上，選擇要還原的資料庫執行個體。

1. 針對 **Actions** (動作)，選擇 **Restore to point in time** (還原至時間點)。

1. 選擇 **Latest restorable time (最近的可還原時間)** 以還原最近一次的可能時間，或選擇 **Custom (自訂)** 以選擇一個時間。

   如果您選擇 **Custom (自訂)**，請輸入您希望執行個體還原到什麼日期和時間。
**注意**  
會以您的當地時區顯示時間，根據國際標準時間 (UTC) 的時差來表示。例如，UTC-5 是東部標準時間/中部日光節約時間。

1. 對於 **DB Instance Identifier** (資料庫執行個體識別符)，輸入目標還原資料庫執行個體的名稱。

1. (選用) 視需要選擇其他選項，例如啟用自動調整規模。

1. 選擇 **Restore to point in time (還原至時間點)**。

## AWS CLI
<a name="AutomatedBackups.PiTR.CLI"></a>

使用 [https://docs.aws.amazon.com/cli/latest/reference/rds/restore-db-instance-to-point-in-time.html](https://docs.aws.amazon.com/cli/latest/reference/rds/restore-db-instance-to-point-in-time.html) AWS CLI 命令建立新的資料庫執行個體。

**從複寫備份將資料庫執行個體還原至指定的時間**
+ 請執行下列其中一個命令：

  對於 Linux、macOS 或 Unix：

  ```
  1. aws rds restore-db-instance-to-point-in-time \
  2.     --source-db-instance-automated-backups-arn "arn:aws:rds:us-east-1:123456789012:auto-backup:ab-L2IJCEXJP7XQ7HOJ4SIEXAMPLE" \
  3.     --target-db-instance-identifier mytargetdbinstance \
  4.     --restore-time 2020-10-14T23:45:00.000Z
  ```

  在 Windows 中：

  ```
  1. aws rds restore-db-instance-to-point-in-time ^
  2.     --source-db-instance-automated-backups-arn "arn:aws:rds:us-east-1:123456789012:auto-backup:ab-L2IJCEXJP7XQ7HOJ4SIEXAMPLE" ^
  3.     --target-db-instance-identifier mytargetdbinstance ^
  4.     --restore-time 2020-10-14T23:45:00.000Z
  ```

## RDS API
<a name="AutomatedBackups.PiTR.API"></a>

若要將資料庫執行個體還原至指定的時間，請搭配下列參數呼叫 [https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_RestoreDBInstanceToPointInTime.html](https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_RestoreDBInstanceToPointInTime.html) Amazon RDS API 操作：
+ `SourceDBInstanceAutomatedBackupsArn`
+ `TargetDBInstanceIdentifier`
+ `RestoreTime`