Labels

Aws (32) MySQL (20) Aurora (12) Rds (7) DynamoDB (6) Cloudformation (4) Python3 (4) Unix (3) MongoDB (1)

Thursday, 4 October 2018

DynamoDB backup and restore

  • On-demand backup allows you to create full backups of your Amazon DynamoDB table for data archiving, helping you meet your corporate and governmental regulatory requirements.
  • Point-in-time recovery (PITR) provides continuous backups of your DynamoDB table data.
  • for the last 35 days until you explicitly turn it off.
  • Fully Managed Backups are automatically encrypted, cataloged, easily discoverable, and retained until you explicitly delete them.
  • Fast and Scalable You can enable PITR or create as many backups for tables of any size, and retain those backups as long as you need them
  • No Performance Impact PITR, backup, and restore do not consume any table provisioned capacity.
  • Additional charges enabling the backuphttps://docs.aws.amazon.com/amazondynamodb/latest/developerguide/BackupRestore.html
  • Backup and restore actions execute with zero impact on table performance or availability.
Consistent data It uses a new and unique distributed technology that allows you to complete backups in seconds regardless of table size.
Performance on-demand backup and restore operations don't affect performance or API latencies.
Region limitation Currently, the backup and restore functionality works in the same Region as the source table.

Backup and Restore: How it works

Along with data, the following are also included (and can't be excluded) on the backups:
  • Global secondary indexes (GSIs)
  • Local secondary indexes (LSIs)
  • Streams
  • Provisioned read and write capacity
  • Restored table items are consistent with LSI projections and eventually consistent with GSI projections.
You must manually set up the following on the restored table:
  • Auto scaling policies
  • AWS Identity and Access Management (IAM) policies
  • Amazon CloudWatch metrics and alarms
  • Tags
  • Stream settings
  • Time To Live (TTL) settings

Creating a Table Backup (AWS CLI)

Create-backup
aws dynamodb create-backup --table-name ecom-seb-5 --backup-name ecom-seb-5-20181004
{
    "BackupDetails": {
    "BackupArn": "arn:aws:dynamodb:eu-west-1:249251296897:table/ecom-seb-5/backup/01538665302978-3d6103c6",
    "BackupName": "ecom-seb-5-20181004",
    "BackupSizeBytes": 4220138,
    "BackupStatus": "CREATING",
    "BackupType": "USER",
    "BackupCreationDateTime": 1538665302.978
    }
}
list-backups
aws dynamodb list-backups
{
    "BackupSummaries": [
    {
        "TableName": "ecom-seb-5",
        "TableId": "cb52bc9d-6a9b-4c66-8063-0e831026326a",
        "TableArn": "arn:aws:dynamodb:eu-west-1:249251296897:table/ecom-seb-5",
        "BackupArn": "arn:aws:dynamodb:eu-west-1:249251296897:table/ecom-seb-5/backup/01538665302978-3d6103c6",
        "BackupName": "ecom-seb-5-20181004",
        "BackupCreationDateTime": 1538665302.978,
        "BackupStatus": "AVAILABLE",
        "BackupType": "USER",
        "BackupSizeBytes": 4220138
    }
    ]
}
Describe-backup
aws dynamodb describe-backup  --backup-arn arn:aws:dynamodb:eu-west-1:249251296897:table/ecom-seb-5/backup/01538665302978-3d6103c6
{
    "BackupDescription": {
    "BackupDetails": {
        "BackupArn": "arn:aws:dynamodb:eu-west-1:249251296897:table/ecom-seb-5/backup/01538665302978-3d6103c6",
        "BackupName": "ecom-seb-5-20181004",
        "BackupSizeBytes": 4220138,
        "BackupStatus": "AVAILABLE",
        "BackupType": "USER",
        "BackupCreationDateTime": 1538665302.978
    },
    "SourceTableDetails": {
        "TableName": "ecom-seb-5",
        "TableId": "cb52bc9d-6a9b-4c66-8063-0e831026326a",
        "TableArn": "arn:aws:dynamodb:eu-west-1:249251296897:table/ecom-seb-5",
        "TableSizeBytes": 4220138,
        "KeySchema": [
        {
            "AttributeName": "Id",
            "KeyType": "HASH"
        }
        ],
        "TableCreationDateTime": 1537882774.703,
        "ProvisionedThroughput": {
        "ReadCapacityUnits": 5,
        "WriteCapacityUnits": 25
        },
        "ItemCount": 82803
    },
    "SourceTableFeatureDetails": {}
    }
}

Restoring a Table from a Backup (AWS CLI)

Confirm the backup that you want to restore
aws dynamodb list-backups
describe-backup To get additional details for the backup, use the describe-backup
aws dynamodb describe-backup  --backup-arn arn:aws:dynamodb:eu-west-1:249251296897:table/ecom-seb-5/backup/01538665302978-3d6103c6
restore-table-from-backup
aws dynamodb restore-table-from-backup --target-table-name ecom-seb-5-restored-20181004 --backup-arn arn:aws:dynamodb:eu-west-1:249251296897:table/ecom-seb-5/backup/01538665302978-3d6103c6
{
    "TableDescription": {
    "AttributeDefinitions": [
        {
        "AttributeName": "Id",
        "AttributeType": "S"
        }
    ],
    "TableName": "ecom-seb-5-restored-20181004",
    "KeySchema": [
        {
        "AttributeName": "Id",
        "KeyType": "HASH"
        }
    ],
    "TableStatus": "CREATING",
    "CreationDateTime": 1538665784.533,
    "ProvisionedThroughput": {
        "NumberOfDecreasesToday": 0,
        "ReadCapacityUnits": 5,
        "WriteCapacityUnits": 25
    },
    "TableSizeBytes": 0,
    "ItemCount": 0,
    "TableArn": "arn:aws:dynamodb:eu-west-1:249251296897:table/ecom-seb-5-restored-20181004",
    "TableId": "138cb61e-1f3a-426b-b05d-b9a716e38dc2",
    "RestoreSummary": {
        "SourceBackupArn": "arn:aws:dynamodb:eu-west-1:249251296897:table/ecom-seb-5/backup/01538665302978-3d6103c6",
        "SourceTableArn": "arn:aws:dynamodb:eu-west-1:249251296897:table/ecom-seb-5",
        "RestoreDateTime": 1538665302.978,
        "RestoreInProgress": true
    }
    }
}
Monitoring the restore
aws dynamodb describe-table --table-name ecom-seb-5-restored-20181004
restore-table-to-point-in-time to be continued..