Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

To create your EC2 instance follow "(1) EC2 Instance Requirements" , requirements can be found on this wiki page.

Be sure you select a t2.medium instance type, and add the private application subnet in order to connect.

You will then need to add the necessary security groups to your EC2 instance to enable communication to RDS. Look for the security groups with "DatabaseVpcSecurityGroup" and "LambdaSecurityGroup" in the name and add them to your instance.

...

If this is your first time connecting you will need to install postgresql in order to connect to RDS:

$ sudo amazon-linux-extras enable postgresql10
$ sudo yum clean metadata
$ sudo yum install postgresql

(may need to specify version such as sudo yum install postgresql15) we can find which version is currently supported with

sudo yum search "postgres"

Connect to RDS from EC2 Instance

...

You will be prompted for the database password

Backup Database

Database Dump

...

$ pg_dump --host=HOST_VALUE --port=5432 --username=USERNAME_VALUE --dbname=DBNAME_VALUE VALUE --password --no-owner --if-exists --clean -W --file=FILENAME.sql

If you want just a specific table from a database you can pass the --table "<table-name>" to the pg_dump cmd to only dump tables that match the regex

You will be prompted for the database password


This will create "FILENAME.sql" on your EC2 instance. This file can be used to restore an RDS database with all of the values dumped from the previous database, or transferred to S3 in order to download

...

$ psql --host=HOST_VALUE --port=5432 --username=USERNAME_VALUE --dbname=DBNAME_VALUE --password --file FILENAME.sql

You will be prompted for the database password