Skip to content

Creating, recreating, or restoring a database from a backup

Carlo Costino edited this page Mar 17, 2017 · 2 revisions

In order to create, recreate, or restore an RDS instance from a backup, those backups must be available first. You must either have automatic snapshots being taken, a manual snapshot(s) created, and/or have a final backup created.

NOTE: In the case of recreating a database using its own snapshots, you can't use any automated snapshots because when the DB is being destroyed, the automated snapshots will be destroyed too.

To create a database from a snapshot

  1. Login to the Amazon RDS console and go to the Snapshots section.

  2. Find the snapshot you want to use and click on it to expand the details. Find the DB Snapshot Name parameter and copy the value. If you don't see a snapshot you want to use, create one first.

  3. In the terraform config you must set or modify the following:

    1. snapshot_identifier to the DB Snapshot Name value you copied
  4. Leave the name property out or comment it out for now (C-style block comment syntax: /* name = "fec" */).

  5. Review and merge the pull request.

This will do the following:

  • Create the database instance with whatever configuration you set.
  • Perform a restore using the specific snapshot.

To recreate a database using its own snapshot

  1. In the terraform config you must set or modify the following:

    1. final_snapshot_identifier to a name of your choosing (must contain only letters, digits, or hyphens)
    2. snapshot_identifier to the same name as final_snapshot_identifier
    3. lifecycle to just an empty config: {}
    4. comment out the name property (C-style block comment syntax): /* name = "fec" */
  2. Make any other changes that necessitate recreating the database.

  3. Review and merge the pull request.

This will do the following:

  • Create a final back up of the database being recreated before destroying it.
  • Destroy the database and create it again with whatever new configuration you set.
  • Restore the final state of the previous instance of the database.