Skip to content

Instantly share code, notes, and snippets.

View ConorCorp's full-sized avatar

Conor ConorCorp

View GitHub Profile
@ConorCorp
ConorCorp / how-to-copy-aws-rds-to-local.md
Last active February 14, 2024 16:32 — forked from syafiqfaiz/how-to-copy-aws-rds-to-local.md
How to copy production database on AWS RDS(postgresql) to local development database.
  1. Change your database RDS instance security group to allow your machine to access it.
    • Add your ip to the security group to access the instance via Postgres.
  2. Make a copy of the database using pg_dump
    • $ pg_dump -h <public dns> -U <my username> -f <name of dump file .sql> <name of my database>
    • you will be asked for postgressql password.
    • a dump file(.sql) will be created
    • Make sure rds has Publicly Accessible checked. This can be done/undone immediately without db downtime.
  3. Restore that dump file to your local database.
    • but you might need to drop the database and create it first
  • $ psql -U -d -f