0

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?

0
2

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.

0

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

this command does a dump and pipes the result to a local session, no copy is stored.

Assuming bash (or compatible shell) If you want to do the same but also store a copy do:

pg_dump -C -h remotehost -U remoteuser db_name | tee /tmp/copy-of-dump | psql localhost -U localuser

or you can make a dump of your local instance

pg_dump localhost -U localuser > /tmp/dump-of-local

if you want a compressed dump: tee >( gzip > /tmp/dump-of-remote.gz )

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.