Postgresql – Retrieving database dump after copying from remote server

pg-dumppostgresql

I used command

pg_dump -C -h remotehost -U remoteuser db_name | psql localhost -U localuser

to copy database on remote server to my local machine.

Can I somehow retreive the dump obtained after the first part of the command, i.e.

pg_dump -C -h remotehost -U remoteuser db_name 

is executed? Can it be stored in some temporary location?

Best Answer

The first command does not store the created file anywhere, so the answer is: no, you can't retrieve that file because there is none.

If you need such a file, you can either re-run the first statement and provide a filename using the -f switch.

Or, if f you have not yet changed your local database, then you can simply dump that.