开发者

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!


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


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:

root@1.2.3.4: su postgres
postgres@1.2.3.4: pg_dump -c A | psql -h 5.6.7.8 A

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜