How Point-in-Time Recovery Works in Amazon Keyspaces - Amazon Keyspaces (for Apache Cassandra)

How Point-in-Time Recovery Works in Amazon Keyspaces

This section provides an overview of how Amazon Keyspaces point-in-time recovery (PITR) works. For more information about pricing, see Amazon Keyspaces (for Apache Cassandra) pricing.

Enabling Point-in-Time Recovery (PITR)

You can enable PITR by using the AWS Management Console, or you can enable it programmatically.

Enabling PITR with the AWS Management Console

You can enable PITR on new tables created in Amazon Keyspaces by selecting the Enable Point-in-time recovery check box in the console. This check box is selected by default.

To enable PITR for an existing table, complete the following steps.

  1. Open the Amazon Keyspaces console at https://console.aws.amazon.com/keyspaces/home.

  2. In the navigation pane, choose Tables and select the table you want to edit.

  3. On the Backups tab, choose Edit.

  4. In the Edit point-in-time recovery settings section, select Enable Point-in-time recovery.

You can disable PITR on a table at any time with the following steps.

  1. Open the Amazon Keyspaces console at https://console.aws.amazon.com/keyspaces/home.

  2. In the navigation pane, choose Tables and select the table you want to edit.

  3. On the Backups tab, choose Edit.

  4. In the Edit point-in-time recovery settings section, clear the Enable Point-in-time recovery check box.

Important

Disabling PITR deletes your backup history immediately, even if you reenable PITR on the table within 35 days.

To learn how to restore a table using the AWS Management Console, see Restoring a Table to a Point in Time (console).

Enabling PITR Programmatically

You can manage PITR settings for tables by using the point_in_time_recovery custom property.

When creating a new table using CQL, you must explicitly enable PITR when you create the new table.

To enable PITR when you're creating a new table, you can use the following CQL command as an example.

CREATE TABLE "my_keyspace1"."my_table1"( "id" int, "name" ascii, "date" timestamp, PRIMARY KEY("id")) WITH CUSTOM_PROPERTIES = { 'capacity_mode':{'throughput_mode':'PAY_PER_REQUEST'}, 'point_in_time_recovery':{'status':'enabled'} }
Note

If no point-in-time recovery custom property is specified, point-in-time recovery is disabled by default.

To enable PITR for an existing table using CQL, run the following CQL command.

ALTER TABLE mykeyspace.mytable WITH custom_properties = {'point_in_time_recovery': {'status': 'enabled'}}

To disable PITR on an existing table, run the following CQL command.

ALTER TABLE mykeyspace.mytable WITH custom_properties = {'point_in_time_recovery': {'status': 'disabled'}}
Important

Disabling PITR deletes your backup history immediately, even if you reenable PITR on the table within 35 days.

For more information in the CQL Language Reference, see CREATE TABLE and ALTER TABLE. To learn how to restore a table using CQL, see Restoring a Table to a Point in Time with CQL.

Time Window for PITR Continuous Backups

Amazon Keyspaces PITR uses two timestamps to maintain the time frame for which restorable backups are available for a table.

  • Earliest restorable time – Marks the time of the earliest restorable backup. The earliest restorable backup goes back up to 35 days or when PITR was enabled, whichever is more recent. The maximum backup window of 35 days can't be modified.

  • Current time – The timestamp for the latest restorable backup is the current time. If no timestamp is provided during a restore, current time is used.

When PITR is enabled, you can restore to any point in time between EarliestRestorableDateTime and CurrentTime. You can only restore table data to a time when PITR was enabled.

If you disable PITR and later reenable it again, you reset the start time for the first available backup to when PITR was reenabled. This means that disabling PITR erases your backup history.

Note

Data definition language (DDL) operations on tables, such as schema changes, are performed asynchronously. You can only see completed operations in your restored table data, but you might see additional actions on your source table if they were in progress at the time of the restore. For a list of DDL statements, see DDL Statements (Data Definition Language) in Amazon Keyspaces.

A table doesn't have to be active to be restored. You can also restore deleted tables if PITR was enabled on the deleted table and the deletion occurred within the backup window (or within the last 35 days).

Note

If a new table is created with the same qualified name (for example, mykeyspace.mytable) as a previously deleted table, the deleted table will no longer be restorable. If you attempt to do this from the AWS Management Console, a warning is displayed.

PITR Restore Settings

When you restore a table using PITR, Amazon Keyspaces restores your source table's schema and data to the state based on the selected timestamp (day:hour:minute:second) to a new table. PITR doesn't overwrite existing tables.

In addition to the table's schema and data, PITR restores the custom_properties from the source table. Unlike the table's data, which is restored based on the selected timestamp between earliest restore time and current time, custom properties are always restored based on the table's settings as of the current time.

The settings of the restored table match the settings of the source table with the timestamp of when the restore was initiated. If you want to overwrite these settings during restore, you can do so using WITH custom_properties. Custom properties include the following settings.

  • Read/write capacity mode

  • Provisioned throughput capacity settings

  • PITR settings

When you do a full table restore, all table settings for the restored table come from the current settings of the source table at the time of the restore.

For example, suppose that a table's provisioned throughput was recently lowered to 50 read capacity units and 50 write capacity units. You then restore the table's state to three weeks ago. At this time, its provisioned throughput was set to 100 read capacity units and 100 write capacity units. In this case, Amazon Keyspaces restores your table data to that point in time, but uses the current provisioned throughput settings (50 read capacity units and 50 write capacity units).

The following settings are not restored, and you must configure them manually for the new table.

  • Automatic scaling policies (for tables that use provisioned capacity mode)

  • AWS Identity and Access Management (IAM) policies

  • Amazon CloudWatch metrics and alarms

  • Tags (can be added to the CQL RESTORE statement using WITH TAGS)

Table Restore Time with PITR

The time it takes you to restore a table is based on multiple factors and isn't always correlated directly to the size of the table.

The following are some considerations for restore times.

  • You restore backups to a new table. It can take up to 20 minutes (even if the table is empty) to perform all the actions to create the new table and initiate the restore process.

  • Restore times for large tables with well distributed data models can be several hours or longer.

  • If your source table contains data that is significantly skewed, the time to restore might increase. For example, if your table’s primary key is using the month of the year as a partition key, and all your data is from the month of December, you have skewed data.

Amazon Keyspaces PITR and Integration with AWS Services

The following PITR operations are logged using AWS CloudTrail to enable continuous monitoring and auditing.

  • Create a new table with PITR enabled or disabled.

  • Enable or disable PITR on an existing table.

  • Restore an active or a deleted table.

For more information, see Logging Amazon Keyspaces API Calls with AWS CloudTrail.