I'm looking to copy a production PostgreSQL database to a development server. What's the quickest, easiest way to go about doing this?
Join them; it only takes a minute:
|
You don't need to create an intermediate file. You can do
or
using With a big database or a slow connection, dumping a file and transfering the file compressed may be faster. As Kornel said there is no need to dump to a intermediate file, if you want to work compressed you can use a compressed tunnel
or
but this solution also requires to get a session in both ends. |
|||||||||||||||||||||
|
Then copy the backup to your development server, restore with:
|
|||||||||||||||||
|
Use pg_dump, and later psql or pg_restore - depending whether you choose -Fp or -Fc options to pg_dump. Example of usage:
|
|||
|
|
|||||||||
|
If you are looking to migrate between versions (eg you updated postgres and have 9.1 running on localhost:5432 and 9.3 running on localhost:5434) you can run:
Check out the migration docs. |
|||
|
Run this command with database name, you want to backup, to take dump of DB.
Now scp this dump file to remote machine where you want to copy DB.
On remote machine run following command in ~/some/folder to restore the DB.
|
||||
|
I struggled quite a lot and eventually the method that allowed me to make it work with Rails 4 was: on your old server
I had to use the postgres linux user to create the dump. also i had to use -c to force the creation of the database on the new server. --inserts tells it to use the INSERT() syntax which otherwise would not work for me :( then, on the new server, simpy:
to transfer the dump.sql file between server I simply used the "cat" to print the content and than "nano" to recreate it copypasting the content. Also, the ROLE i was using on the two database was different so i had to find-replace all the owner name in the dump. |
||||
|
protected by durron597 Sep 18 '15 at 13:54
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?