Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pgAdmin3 backup over ssh tunnel

I have a running postgresql server on amazone ec2. I connect with pgAdmin3 to it over ssh tunnel directly configured in pgAdmin3 from my mac. I can make queries and see the full schema, no problem about that.

If I try to make a backup of the database (from pgAdmin3 GUI) then I get (even if the connection is actually 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 can not connect over the ssh tunnel?

like image 390
Adrian Avatar asked Sep 04 '15 12:09

Adrian


People also ask

How do I connect to a server on pgadmin3?

Connecting to a Database with pgAdmin III After running OpenVPN as administrator and establishing a connection you should also run pgAdmin III. Establish a new connection from File -> Add Server… menu (the first icon in the toolbar). Enter the details to connect to the database in the New Server Registration window.

How do I connect to SSH on pgAdmin?

You can use the “SSH Tunnel” tab to connect pgAdmin (through an intermediary proxy host) to a server that resides on a network to which the client may not be able to connect directly. Set “Use SSH tunneling” to Yes to specify that pgAdmin should use an SSH tunnel when connecting to the specified server.


1 Answers

alternative until i found a solution is to make it by terminal

ssh <HOST> "pg_dump -U <USERNAME> -W -h localhost -F c <DATABASENAME> | gzip -c" > ./backup.sql.gz
like image 141
Adrian Avatar answered Oct 18 '22 04:10

Adrian