Pg_dump from remote server to localhost

Hi, can someone help me dump a postgreSQL database on a remote AWS server into a postgreSQL database on my local machine.

I am trying to do this using the answer in this column, but it continues to fail.

The command I use

pg_dump -C -h ssh ubuntu@ec2-59-16-143-85.eu-west-1.compute.amazonaws.com -U dev_user paycloud_dev | psql -h localhost -U dev_user paycloud_dev

But I keep getting the error

pg_dump: too many command-line arguments (first is "paycloud_dev")

I can not understand what I'm doing wrong

Just to add dev_user, this is the role that I installed in postgreSQL on both the local computer and the remote server. paycloud_devis the database name for both (owner dev_user)

Change 1

Tried the command below according to a message that has since been deleted for some reason

pg_dump -C -h ec2-59-16-143-85.eu-west-1.compute.amazonaws.com -U dev_user paycloud_dev | psql -h localhost -U dev_user paycloud_dev 

Now it gives me an error

pg_dump: [archiver (db)] connection to database "paycloud_dev" failed: could not connect to server: Connection refused
Is the server running on host "ec2-59-16-143-85.eu-west-1.compute.amazonaws.com" (59.16.143.85) and accepting
TCP/IP connections on port 5432?

AWS , ip . ( IP-)

pg_dump -C -h 170.30.43.35 -U dev_user paycloud_dev | psql -h localhost -U dev_user paycloud_dev

paycloud_dev, , 2 3 :

pg_dump: [archiver (db)] connection to database "paycloud_dev" failed: could not connect to server: Connection refused
Is the server running on host "170.30.43.35" and accepting
TCP/IP connections on port 5432?

AWS, , ( 0-65535), .

2

pokoli

ssh ubuntu@ec2-59-16-143-85.eu-west-1.compute.amazonaws.com pg_dump -C -h  -U dev_user paycloud_dev | psql -U dev_user paycloud_dev

. psql , - , .

[sudo] password for alzer: pg_dump: too many command-line arguments (first is "paycloud_dev")

"pg_dump --help" .

-?

+4
2

ssh , . :

ssh ubuntu@ec2-59-16-143-85.eu-west-1.compute.amazonaws.com -C pg_dump  -U dev_user paycloud_dev | psql -U dev_user paycloud_dev

, , playcloud_dev , .

+4

ssh.

ssh -fT -L 5432:127.0.0.1:5432 %remote_user_login%@%your_aws_host% sleep 10
pg_dump -C -h localhost -U dev_user paycloud_dev | psql -h localhost -U dev_user paycloud_dev

ssh.

AWS " ", , .

+2

All Articles