2015-09-04 270 views
7

我在amazone ec2上運行postgresql服務器。我通過pgAdmin3通過ssh隧道連接到它,直接在我的mac中在pgAdmin3中配置。 我可以查詢並查看完整的模式,對此沒有任何問題。pgAdmin3通過ssh隧道備份

如果我試圖使數據庫(從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 
 
\t Is the server running on host "localhost" (::1) and accepting 
 
\t TCP/IP connections on port 5432? 
 
could not connect to server: Connection refused 
 
\t Is the server running on host "localhost" (127.0.0.1) and accepting 
 
\t TCP/IP connections on port 5432? 
 

 
Process ended with Exitcode 1.

任何想法爲什麼背景中的pg_dump無法通過SSH隧道連接?

+1

我也想知道爲什麼pgAdmin的不支持此功能。這是一個已知的錯誤嗎? – Karens

回答

1

替代,直到我發現了一個解決方法是通過終端

ssh <HOST> "pg_dump -U <USERNAME> -W -h localhost -F c <DATABASENAME> | gzip -c" > ./backup.sql.gz 
0

這條線工作對我來說,使它:

ssh -o "Compression=no" server_adress "pg_dump -Z9 -Fc -U postgres db_name" > backup_name.dump