【问题标题】:How can I use pg_dump to backup postgresql to remote host?如何使用 pg_dump 将 postgresql 备份到远程主机?
【发布时间】:2011-02-16 15:41:37
【问题描述】:

我需要将本地服务器两个 postgresql 数据库备份到远程主机,使用pg_dump 命令而不使用 ssh。本地服务器和远程主机都安装postgresql。

我该怎么做?

如:

数据库名称:A,B

本地服务器:1.2.3.4

远程服务器:5.6.7.8

谢谢!

【问题讨论】:

    标签: postgresql backup host


    【解决方案1】:

    从远程主机,使用 pg_dump 的 --host 选项从本地服务器进行转储。

    【讨论】:

    • 我可以从本地服务器备份到远程主机吗?
    【解决方案2】:

    如果有人通过谷歌找到这个问题:

    就像用户 postgres 在本地主机上所做的那样:

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

    例如对于 1.2.3.4 上的 DB A:

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

    “-c”创建了 drop/create 语句,所以要小心 ;)

    【讨论】:

      猜你喜欢
      • 2015-06-29
      • 2021-02-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-01-26
      • 2011-03-03
      相关资源
      最近更新 更多