使用 Amazon Keyspaces PITR 还原已删除的表 - Amazon Keyspaces(Apache Cassandra 兼容)
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

使用 Amazon Keyspaces PITR 还原已删除的表

以下过程展示了如何将已删除的表从备份中还原到删除时的状态。您可以使用 CQL 或. Amazon CLI

注意

此过程假定您已为删除的表启用 PITR。

Cassandra Query Language (CQL)
使用 CQL 还原已删除的表
  1. 要确认已对已删除的表启用了 point-in-time恢复,请查询系统表。仅显示启用了 point-in-time恢复功能的表。

    SELECT custom_properties FROM system_schema_mcs.tables_history WHERE keyspace_name = 'mykeyspace' AND table_name = 'my_table';

    该查询会显示以下输出。

    custom_properties ------------------ { ..., "point_in_time_recovery":{ "restorable_until_time":"2020-08-04T00:48:58.381Z", "status":"enabled" } }
  2. 使用以下示例语句将表还原到删除时的状态。

    RESTORE TABLE mykeyspace.mytable_restored FROM TABLE mykeyspace.mytable;
CLI
使用恢复已删除的表 Amazon CLI
  1. 删除您之前创建且启用了 PITR 的表。以下命令是一个示例。

    aws keyspaces delete-table --keyspace-name 'myKeyspace' --table-name 'myTable'
  2. 使用以下命令将已删除的表还原到删除时的状态。

    aws keyspaces restore-table --source-keyspace-name 'myKeyspace' --source-table-name 'myTable' --target-keyspace-name 'myKeyspace' --target-table-name 'myTable_restored2'

    此命令的输出会返回已还原的表的 ARN。

    { "restoredTableARN": "arn:aws:cassandra:us-east-1:111222333444:/keyspace/myKeyspace/table/myTable_restored2" }