Byte Ebi's Logo

Byte Ebi 🍤

A Bit everyday A Byte every week

AWS DynamoDB Point-in-Time Recovery (PITR): Simplifying Data Restoration

Point-in-Time Recovery (PITR) allows you to restore your data to a specific moment in time, ensuring data integrity and minimizing potential data loss.

Ray

Point-in-Time Recovery (PITR) is a crucial data recovery feature for AWS DynamoDB and other database services.
It allows you to restore data to a previous state in case of accidental loss or corruption, ensuring business continuity.
PITR also enables regular data backups and retention of multiple versions, aiding in error tracking and resolution.
It’s flexibility in restoring data on demand without affecting other operations enhances system reliability and stability.

Introduction

Continuous Backup and Point-in-Time Recovery (PITR)

Amazon DynamoDB’s PITR feature enables table restoration to any past point, using automatic incremental backups to safeguard against accidental data loss.
Enabling PITR triggers DynamoDB to create backups every second, allowing restoration to any point within the last 35 days.
To restore a table, specify the date and time via the AWS Management Console, AWS CLI, or DynamoDB API.

Advantages of PITR:

  • Helps protect DynamoDB tables from accidental deletion or write operations.
  • Allows tables to be restored to any point in the past.
  • Easy to use.

Limitations of PITR:

  • Additional cost may be required.
  • May affect the performance of the table.

Enabling PITR using Terraform

aws_dynamodb_table point_in_time_recovery

resource "aws_dynamodb_table" "my_table" {
  name = "my-table"
  hash_key = "id"
  billing_mode = "PAY_PER_REQUEST"

  point_in_time_recovery {
    enabled = true
    retention_period_days = 35
  }
}

In this example, we use the point_in_time_recovery resource to specify the PITR configuration.
We set the enabled parameter to true to enable PITR.
We also set the retention_period_days parameter to 35 days to specify the backup retention period.

deletion_protection_enabled

The deletion_protection_enabled tag is a DynamoDB tag that can be used to prevent a table from being accidentally deleted.
When this tag is added to a table, DynamoDB will refuse to delete the table, even if deletion is attempted using the AWS Management Console, AWS CLI, or DynamoDB API.

Operating PITR

AWS Management Console

To operate PITR using the AWS Management Console, follow these steps:

  1. In the AWS Management Console, navigate to the DynamoDB service.
  2. Select your table.
  3. In the left navigation pane, choose Point-in-time recovery.

Enabling PITR

To enable PITR, select Enable point-in-time recovery.

Specifying Backup Retention Period

You can specify the backup retention period.
The backup retention period is in days and can be a minimum of 1 day and a maximum of 35 days.

Restoring a Table

To restore a table to a past point in time, select Restore table.

  1. Specify the restore date and time.
  2. Specify the date and time for the table to be restored.
  3. Save the changes.
  4. Select Restore.

AWS CLI

To operate PITR using the AWS CLI, you can use the following commands:

Enabling PITR

To enable PITR, use the following command:

aws dynamodb enable-point-in-time-recovery --table-name my-table

Specifying Backup Retention Period

To specify the backup retention period, use the following command:

aws dynamodb update-table --table-name my-table --point-in-time-recovery-retention-period-in-days 35

Restoring a Table

To restore a table to a past point in time, use the following command:

aws dynamodb restore-table-from-point-in-time --table-name my-table --restore-time 2023-08-02T12:00:00Z

Recent Posts

Categories

Tags