0

I have 2 Postgres RDS instances:

  • Postgres RDS 1
  • Postgres RDS 2

I have a 10 tables available in Postgres RDS 1 which I need to migrate to Postgres RDS 2.

Can I use pg_dump to directly transfer the tables?

pg_dump -t test_migration -h postgresrds2.cr8o9qw9mt1v.us-east-1.rds.amazonaws.com -U postgres -d postgres | psql -d myschema -h postgresrds1.cr8o9qw9mt1v.us-east-1.rds.amazonaws.com -U myadminuser

I am also aware of migrating table to S3, but I don't want to do that because it will consume a lot of time.

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
dang
  • 2,342
  • 5
  • 44
  • 91
  • Yes, using `pg_dump | psql` should work nicely. Are your database names backwards, however? – John Rotenstein Feb 03 '20 at 11:07
  • Issue with `pg_dump | psql` is -- it asks for only 1 password and NOT 2 passwords. Because of which it breaks. – dang Feb 03 '20 at 14:13
  • [How to pass in password to pg_dump?](https://stackoverflow.com/q/2893954/174777), [Copy a table from one database to another in Postgres](https://stackoverflow.com/q/3195125/174777), [Copying PostgreSQL database to another server](https://stackoverflow.com/a/55645207/174777) – John Rotenstein Feb 03 '20 at 21:49

1 Answers1

0

Depending on the complexity you might want to look into the Database Migration Service. If the migration you are performing isn't to hard it's probably easier to just use pgdump | psql but if you're migrating larger tables (1+ million rows) using DMS might be easier.

Exelian
  • 5,749
  • 1
  • 30
  • 49