Say we have a database A hosted at my.first.database.com
loaded with data, and we want to replicate this data over database B, located at my.second.database.com
. We suppose database A and B have identical schemas, and both databases are accessible via port 5432.
pg_dump --data-only \
-h my.first.database.com \
-U {database_user} \
-f /tmp/dump.sql \
-T={table pattern to exclude [optional]} \
{database_name}
psql \
-h my.second.database.com \
-U {db_user} \
{db_name} < /tmp/dump.sql