2

I see that there are solutions for copying tables from one Postgres SQL server to another. But I need to transfer ONLY DATA from one server to another. I noticed the following command:

pg_dump -C -h localhost -U localuser dbname | psql -h remotehost -U remoteuser dbname

But I do not want to copy anything else other than data. How can I do that?

Another question. I have multiple tables on Server A. If I want to copy Data from all tables on Server A to Server B, how can I do that? Thank you.

1 Answer 1

2

To copy only the data with pg_dump, you can use the -a flag (or the long form would be --data-only):

pg_dump -C --data-only -h localhost -U localuser dbname | psql -h remotehost -U remoteuser dbname
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you! Will that copy data from all tables? If I want to deselect a table, do we have that option? For example, if there are 3 tables: tab1, tab2, tab3, can I deselect tab2? I really appreciate your help.
yes, you can use --exclude-table or the -T option. You can find more information about pg_dump here: postgresql.org/docs/current/app-pgdump.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.