In our practice, so far we did:
1. We created a table named 'students'.2. We took one backup of that table named 'students-bkp' by using AWS console and another backup named 'students-bkp-cli' using AWS CLI.
3. We deleted the table named 'students'
4. We restored the data from backup 'students-bkp' and named it 'students-restore'
5. Now, again we will delete the table named 'students-restore' and
6. Again restore the data using backup 'students-bkp-cli' by using AWS CLI.
Now we are going to restore the DynamoDB database from our taken backup named 'students-bkp-cli'.
Steps we need to follow:
1. Delete the table named 'students-restore'2. Login to AWS CLI from user 'Charlie'
3. Confirm the backup by using command 'list-backups'
4. Restore the table from backup
5. Verify the restore
Step 1: Delete the table named 'students-restore':
AWS ➔ Services ➔ DynamoDB ➔ Tables ➔ select table 'students-restore' ➔ Delete table ➔ Delete.
Now, our table has been deleted, which we need to recover from backup named 'students-bkp-cli'.
Step 2: Login to AWS CLI from user 'Charlie':
We will login by user Charlie because, at the time of backup, we created this user named 'Charlie' to access the database. Open PowerShell and use below-mentioned commands:C:\> aws configure
C:\> AWS Access Key ID: <provide the .csv file which you downloaded>
C:\> AWS Secret Access Key ID: <provide the .csv file which you downloaded>
C:\> Default region name: us-east-1
C:\> Default output format: table
Fig: Login into AWS CLI |
Step 3: Confirm the backup by using command 'list-backups':
Fig: List all Backups using AWS CLI |
Here, we can see that a backup named 'students-bkp-cli' is available.
Step 4: Restore the table from backup:
For this use below-mentioned command:Syntax:
C:\> aws dynamodb restore-table-from-backup \
--target-table-name <provide_a_name_for_your_table> \
--backup-arn <Backup_ARN>
Example:
C:\> aws dynamodb restore-table-from-backup \
--target-table-name students-cli-restore \
--backup-arn arn:aws:dynamodb:us-east-1:401300871758:table/students/backup/01564256808673-1e23e170
Fig: Restoring the DynamoDB database using AWS CLI |
In AWS console also we can check that the table is in Restoring status:
Fig: Restoring status of DynamoDB Database |
Step 5: Verify the restore:
To verify the restore, use the 'describe-table' command to describe the 'students-cli-restore' table:C:\> aws dynamodb describe-table --table-name students-cli-restore
Fig: 'RestoreInProgress' is 'True' |
We can see that 'RestoreInProgress' is 'True'. After some time the status will be 'Active'.
Fig: TableStatus: Active |
Enjoy!
No comments:
Post a Comment