Restoring an Amazon RDS Instance Using Snapshots

1.5 hours
  • 4 Learning Objectives

About this Hands-on Lab

A critical part of database management is being able to recover your data after corruption or accidental deletion has occurred.

In this hands-on lab, we’ll use the point-in-time restore capability of RDS automated snapshots to restore a database and bring a site back up.

**NOTE**: This lab may take up to 15 minutes to fully start due to the number of resources that need to be provisioned.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Create an RDS Snapshot

Create a manual snapshot of the existing RDS database in this environment.

  1. In the RDS console, choose the running instance.
  2. Select Maintenance & backups > Take snapshot.
  3. Name the snapshot (e.g., "wordpress-YYYYMMDD").
Log in to the Bastion Host and Delete Database Data

Log in to the bastion host via SSH, and, using the mysql command line, drop a critical table from the database.

  1. In the EC2 console, find the public IP of the bastion host.

  2. Log in to the bastion host via SSH as cloud_user using the public IP.

  3. Install the MySQL command line

    sudo yum install mysql
  4. Connect to MySQL:

    mysql --user=wpuser --password=Password1 --host=<RDS ENDPOINT NAME>
  5. At the MySQL prompt, switch to the WordPress database:

    use wordpressdb;
  6. Delete a critical table:

    drop table wp_posts;
Restore an RDS Database from a Snapshot

Use the snapshot you created to create a new database with all the data from before it was corrupted.

  1. In the RDS console, navigate to snapshots.
  2. Note the snapshot creation time.
  3. Navigate to Databases, and select wordpress-database
  4. Under Actions, select Restore to point in time.
  5. Select a custom restore time, and enter the point in time you want to restore from.
  6. Name the recovered database instance "ordpress-recovery"
  7. Select availability zone -east-1b
  8. Launch the database instance.
Rename Database Instances

Rename the wordpress-recovery instance to wordpress-database, and rename wordpress-database to something else.

  1. In the RDS console, select the wordpress-database instance, and click Modify.
  2. Change the DB instance identifier from "wordpress-database" to "wordpress-corrupt".
  3. Click Continue.
  4. Select Apply Immediately.
  5. Click Modify DB Instance.
  6. Follow the above steps to rename "wordpress-recovery" to "wordpress-database".
  7. Select the database security group.
  8. Click Continue.
  9. Select Apply Immediately.
  10. Click Modify DB Instance.
  11. Visit the website and observe that the last known good configuration is present.

Additional Resources

In this scenario, you are a systems administrator for a company with a corporate website powered by WordPress. The developer has just notified you that some unspecified corruption in the database has occurred, and now the site is down and the admin panel cannot be reached.

Your task is to use the point-in-time restore capability of RDS automated snapshots to restore the database and bring the site back up.

Please log in to the lab environment with the cloud_user credentials provided. Make sure you are using us-east-1 region throughout the lab.

Make a note of the cloud_user password for connecting to the bastion instance.

NOTE: This environment will take up to 15 minutes to create.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?