

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

# 從保留的自動備份將資料庫叢集還原到指定的時間
<a name="aurora-pitr-retained"></a>

如果備份在來源叢集的保留期間內，您可以在刪除來源資料庫叢集之後，從保留的自動備份還原資料庫叢集。此程序類似於從自動備份還原資料庫叢集。

## 主控台
<a name="aurora-pitr-retained.CON"></a>

**將資料庫叢集還原至指定時間**

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

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

1. 選擇**保留**標籤。  
![保留的自動備份。](http://docs.aws.amazon.com/zh_tw/AmazonRDS/latest/AuroraUserGuide/images/db-cluster-retained-automated-backups.png)

1. 選擇您要還原的 資料庫叢集。

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

   **Restore to point in time (還原到時間點)** 視窗隨即出現。

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

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

1. 對於**資料庫叢集識別符**，輸入目標還原資料庫叢集的名稱。名稱必須是唯一的。

1. 視需要選擇其他選項，例如資料庫執行個體類別。

   如需每項設定的相關資訊，請參閱 [Aurora 資料庫叢集的設定](Aurora.CreateInstance.md#Aurora.CreateInstance.Settings)。

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

## AWS CLI
<a name="aurora-pitr-retained.CLI"></a>

若要將資料庫叢集還原至指定的時間，請使用 [restore-db-cluster-to-point-in-time](https://docs.aws.amazon.com/cli/latest/reference/rds/restore-db-cluster-to-point-in-time.html) AWS CLI 命令來建立新的資料庫叢集。

您可以指定其他設定。如需每項設定的相關資訊，請參閱 [Aurora 資料庫叢集的設定](Aurora.CreateInstance.md#Aurora.CreateInstance.Settings)。

此操作支援資源標記。使用 `--tags` 選項時，會忽略來源資料庫叢集標籤，並使用提供的標籤。否則，會使用來源叢集中的最新標籤。

**Example**  
對於 Linux、macOS 或 Unix：  

```
1. aws rds restore-db-cluster-to-point-in-time \
2.     --source-db-cluster-resource-id {{cluster-123ABCEXAMPLE}} \
3.     --db-cluster-identifier {{mytargetdbcluster}} \
4.     --restore-to-time {{2017-10-14T23:45:00.000Z}}
```
在 Windows 中：  

```
1. aws rds restore-db-cluster-to-point-in-time ^
2.     --source-db-cluster-resource-id {{cluster-123ABCEXAMPLE}} ^
3.     --db-cluster-identifier {{mytargetdbcluster}} ^
4.     --restore-to-time {{2017-10-14T23:45:00.000Z}}
```

**重要**  
如果您使用主控台來將資料庫叢集還原至指定時間，則 Amazon RDS 會自動建立資料庫叢集的主要執行個體 (寫入器)。如果您使用 AWS CLI 將資料庫叢集還原至指定的時間，則必須明確建立資料庫叢集的主要執行個體。主要執行個體是資料庫叢集內第一個建立的執行個體。  
呼叫 [create-db-instance](https://docs.aws.amazon.com/cli/latest/reference/rds/create-db-instance.html) AWS CLI 命令，為資料庫叢集建立主要執行個體。包含資料庫叢集的名稱做為 `--db-cluster-identifier` 選項值。

## RDS API
<a name="aurora-pitr-retained.API"></a>

若要將資料庫叢集還原至指定的時間，請搭配下列參數呼叫 Amazon RDS API [https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_RestoreDBClusterToPointInTime.html](https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_RestoreDBClusterToPointInTime.html) 操作：
+ `SourceDbClusterResourceId`
+ `DBClusterIdentifier`
+ `RestoreToTime`

**重要**  
如果您使用主控台來將資料庫叢集還原至指定時間，則 Amazon RDS 會自動建立資料庫叢集的主要執行個體 (寫入器)。如果您使用 RDS API 來將資料庫叢集還原至指定時間，請務必明確建立資料庫叢集的主要執行個體。主要執行個體是資料庫叢集內第一個建立的執行個體。  
若要建立資料庫叢集的主要執行個體，請呼叫 RDS API 操作 [CreateDBInstance](https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_CreateDBInstance.html)。包含資料庫叢集的名稱做為 `DBClusterIdentifier` 參數值。