如何pg_dumpall从远程服务器到本地机器和本地机器到远程服务器

How to pg_dumpall from remote server to local machine and local machine to remote server

我需要进行新安装,为此我需要从当前安装复制我的数据库。我需要远程服务器到本地机器的 pg_dumpall 命令。

我已经试过了,但它只对 dump 有效,对 dumpall 无效

pg_dump -h hostname -Fc -o -U username database > databaseall.sql

pg_dumpall -h hostname -p 5432 -U username > databaseall.sql

给出错误

pg_dumpall: query failed: ERROR:  permission denied for relation pg_authid
pg_dumpall: query was: SELECT oid, rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolconnlimit, rolpassword, rolvaliduntil, rolreplication, rolbypassrls, pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, rolname = current_user AS is_current_user FROM pg_authid ORDER BY 2

pg_dumpall -h hostname -p 5432 -U username -c -o -f "databaseall.sql"

给出错误

pg_dumpall: query failed: ERROR:  permission denied for relation pg_authid
pg_dumpall: query was: SELECT rolname FROM pg_authid ORDER BY 1

使用pg_dumpall/psql命令转储和恢复

pg_dumpall > alldb.sql

加载另一个实例

psql -f alldb.sql postgres