如何將我的 Amazon DynamoDB 資料表備份還原至不同的區域?

1 分的閱讀內容
0

我想要將我的 Amazon DynamoDB 資料表備份還原至不同的區域。

解決方案

若要將 DynamoDB 表還原到不同的區域,您可以使用下列其中一種方法。

使用 DynamoDB 將動態資料表還原到不同的區域

  1. 開啟 DynamoDB 主控台
  2. 在導覽窗格中,選擇 Backups (備份)。
  3. 在顯示的清單中,選擇要從中還原表格的備份。
  4. 選擇 Restore (還原)。
  5. 對於 Name of restored table (已還原表格的名稱),輸入新表格名稱。
  6. 對於 Secondary indexes (次要索引),請選取您想要的選項。
  7. 對於 Secondary indexes (目的地 AWS 區域),選取 Cross-Region (跨區域)。
  8. 對於 Select the destination AWS Region (選取目的地 AWS 區域),請選擇您選擇的區域。
  9. 對於 Encryption key management (加密金鑰管理),選取您想要的選項。
  10. 選擇 Restore (還原)。

使用 AWS Glue 將動態資料表還原到不同的區域

您可以使用 AWS Glue 任務將 DynamoDB 表格還原到另一個區域。AWS Glue 在還原程序中提供更大的彈性。如果您不想將所有屬性或欄位還原到新區域中的目標資料表,您可以選擇此方法。此方法僅適用於匯出至 Amazon Simple Storage Service (Amazon S3) 的表格。

1.    使用**匯出至 S3** 功能將 DynamoDB 表格匯出至 Amazon S3 後,請建立 AWS Glue 任務。務必在 Script (指令碼) 標籤中指定下列資訊:

datasource0 = glueContext.create_dynamic_frame.from_options(
    connection_type="dynamodb",
    connection_options={
        "dynamodb.export": "ddb",
        "dynamodb.tableArn": "arn:aws:dynamodb:source-region:account-number:table/TableName",
        "dynamodb.unnestDDBJson": True,
        "dynamodb.s3.bucket": "example-bucket",
        "dynamodb.s3.prefix": "dynamodb",
        "dynamodb.s3.bucketOwner": "account-number",
    }
)

**附註:**務必使用轉換節點 AppplyMapping,並指定目標資料表中必須存在的欄位。此設定會根據提供的輸入自動產生 PySpark 程式碼。

範例:

applymapping1 = ApplyMapping.apply(frame = datasource0, mappings = [("resource_id", "string", "resource_id", "string")], transformation_ctx = "applymapping1")

2.    指定接收作業,直接寫入至目標區域中的目的地資料表。

範例:

glueContext.write_dynamic_frame_from_options (frame = MappedFrame, connection_type = "dynamodb", connection_options = { "dynamodb.region": "example-region", "dynamodb.output.tableName": "example_table", "dynamodb.throughput.write.percent": "1.0" })

3.    從 AWS Glue 主控台執行任務,從目前區域將資料載入至目標區域。


相關資訊

從備份還原動態資料表

DynamoDB 時間點復原

在 AWS Glue 主控台上使用工作

AWS 官方
AWS 官方已更新 2 年前