Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Restore dump on the remote machine

Tags:

I've got my own machine with postgres dmp file, which I want to restore on the remote virtual machine (e.g. ip is 192.168.0.190 and postgres port is 5432) in my network. Is it possible to restore this dump using pg_restore without copying dump to remote machine? Because the size of dump about 12GB and the disk space on the virtual machine is 20GB. Thanks

like image 727
Danila Zharenkov Avatar asked Oct 15 '14 08:10

Danila Zharenkov


People also ask

Where does pg_dump save file?

sql , which uses the plain or SQL format, the pg_dump command does not store any file anywhere. It just sends the output to STDOUT , which is usually your screen, and it's done.

How long does PG dump take?

It took ~60 minutes.

What is Pg_restore?

Description. pg_restore is a utility for restoring a PostgreSQL database from an archive created by pg_dump in one of the non-plain-text formats. It will issue the commands necessary to reconstruct the database to the state it was in at the time it was saved.


1 Answers

You can run a restore over the network without copying the dump to the remote host.

Just invoke pg_restore with -h <hostname> and -p <port> (and probably -U <username> to authenticate as different user) on the host you got the dump file, for example:

pg_restore -h 192.168.0.190 -p 5432 -d databasename -U myuser mydump.dump 

References:

  • pg_restore documentation
like image 142
nif Avatar answered Oct 26 '22 12:10

nif