Backing up pgAdmin3 over ssh tunnel

I have a postgresql server running on amazone ec2. I connect to pgAdmin3 to it through the ssh tunnel, which is directly configured in pgAdmin3 from my mac. I can make requests and see the full diagram, no problem.

If I try to backup the database (from the pgAdmin3 GUI), then I get (even if the connection is really open and working) the following exception:

/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. 

Any idea why pg_dump in the background cannot connect via ssh tunnel?

+7
postgresql backup pgadmin ssh-tunnel
source share
2 answers

until I find a solution - make it a terminal

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

This line worked for me:

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

All Articles