使用 Amazon Keyspaces PITR 还原已删除的表 - Amazon Keyspaces(Apache Cassandra 兼容)

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

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

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

注意

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

Cassandra Query Language (CQL)
使用 CQL 还原已删除的表
  1. 要确认是否为已删除表启用时间点故障恢复,请查询系统表。仅显示已启用时间点故障恢复的表。

    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
使用 AWS 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" }