簡體   English   中英

AWS DynamoDB Java SDK 如何查看表是否啟用了時間點恢復 (PITR)?

[英]AWS DynamoDB Java SDK how to see if Point-in-time recovery (PITR) is enabled on table?

想知道如何知道 PITR 是否已啟用。

對於 AWS Java。

檢查 PointInTimeRecoverySpecification 但沒有成功。 使用 TableDescription 也沒有。

根據文檔,您可以使用DescribeContineousBackupsRequest

檢查指定表的連續備份和時間點恢復的狀態。 在創建表時對所有表啟用連續備份。 如果啟用時間點恢復,PointInTimeRecoveryStatus 將設置為 ENABLED。

啟用連續備份和時間點恢復后,您可以恢復到 EarliestRestorableDateTime 和 LatestRestorableDateTime 內的任意時間點。

LatestRestorableDateTime 通常比當前時間早 5 分鍾。 您可以將表格恢復到過去 35 天內的任何時間點。

您可以以每秒 10 次的最大速率調用 DescribeContinuousBackups。

https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_DescribeContinuousBackups.html

DescribeContinuousBackupsRequest backupsRequest =
                DescribeContinuousBackupsRequest
                        .builder()
                        .tableName("table")
                        .build();

        DescribeContinuousBackupsResponse backupsResponse = dbClient.describeContinuousBackups(backupsRequest);

        if(backupsResponse.continuousBackupsDescription().pointInTimeRecoveryDescription().pointInTimeRecoveryStatus().equals("DISABLED")) {

            result = "false";
            failReason = "Continuous Backup is not enabled for DynamoDB Tables."
                    + "DynamoDB table without backup can result in accidental data loss. Your AWS DynamoDB tables should make use of Point-in-time Recovery "
                    + "(PITR) feature in order to automatically take continuous backups of your DynamoDB data.";
            offenders.add("Table Name: " + tablesResponse.tableNames());

        }

參考: https://github.com/harshangp20/dynamoDBAudit/blob/094041168f6d105675f376c31275074b2c1dea45/src/main/java/org/lambda/service/DynamoDBCheckList.java#L317

DescribeContinuousBackupsRequest backupsRequest = DescribeContinuousBackupsRequest
             .builder().tableName("table").build();

DescribeContinuousBackupsResponse backupsResponse = dbClient.describeContinuousBackups(backupsRequest);

if(backupsResponse.continuousBackupsDescription().pointInTimeRecoveryDescription().pointInTimeRecoveryStatus().equals("DISABLED")) {

   result = "false";
   failReason = "Continuous Backup is not enabled for DynamoDB Tables."
         + "DynamoDB table without backup can result in accidental data loss. Your AWS DynamoDB tables should make use of Point-in-time Recovery "
         + "(PITR) feature in order to automatically take continuous backups of your DynamoDB data.";
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM