通过ssh隧道进行pgAdmin3备份

Adr*_*ian 7 postgresql backup ssh-tunnel pgadmin

我在amazone ec2上运行postgresql服务器.我通过ssh隧道连接pgAdmin3,直接在我的mac的pgAdmin3中配置.我可以查询并查看完整的架构,没有问题.

如果我尝试备份数据库(来自pgAdmin3 GUI),那么我得到(即使连接实际上是打开并正常工作)以下异常:

/Applications/pgAdmin3.app/Contents/SharedSupport/pg_dump --host localhost --port 5432 --username "MY_USERNAME" --role "MY_ROLE" --no-password  --format custom --encoding UTF8 --verbose --file "/Users/XXX/filename" "DATABASENAME"
pg_dump: [archiver (db)] connection to database "DATABASENAME" failed: could not connect to server: Connection refused
	Is the server running on host "localhost" (::1) and accepting
	TCP/IP connections on port 5432?
could not connect to server: Connection refused
	Is the server running on host "localhost" (127.0.0.1) and accepting
	TCP/IP connections on port 5432?

Process ended with Exitcode 1.
Run Code Online (Sandbox Code Playgroud)

知道为什么后台的pg_dump无法通过ssh隧道连接?

Adr*_*ian 1

在我找到解决方案之前,替代方案是通过终端进行

ssh <HOST> "pg_dump -U <USERNAME> -W -h localhost -F c <DATABASENAME> | gzip -c" > ./backup.sql.gz
Run Code Online (Sandbox Code Playgroud)