user618915
user618915

Reputation: 31

How can I use pg_dump to backup postgresql to remote host?

I need backup local server two postgresql databases to remote host, using pg_dump command and not use ssh. local server and remote host are all install postgresql.

how can I do it ?

such as:

database name: A,B

local server:1.2.3.4

remote server:5.6.7.8

Thanks!

Upvotes: 2

Views: 11021

Answers (2)

Lefois
Lefois

Reputation: 21

Just if somebody finds to this question via google:

as user postgres do on the localhost:

pg_dump -c <db_name> | psql -h <remotehost> <target_db_name>

e.g. for DB A on 1.2.3.4:

[email protected]: su postgres
[email protected]: pg_dump -c A | psql -h 5.6.7.8 A

The "-c" creates the drop/create statements, so take care ;)

Upvotes: 1

Andy Lester
Andy Lester

Reputation: 93676

From the remote host, use pg_dump's --host option to do the dump from the local server.

Upvotes: 6

Related Questions