So there's a database on a dev machine server that I ssh into to write code. I want to copy the database from there to my local machine. But I can't get the following to work. Can you tell me what's wrong and where to go from here? (See image)
-
1So just ssh into that machine and run pg_dump locally, then copy the files to your computer with scpe4c5– e4c52016-05-10 05:28:56 +00:00Commented May 10, 2016 at 5:28
-
Where would it put that file? Is it this command? Backup: $ pg_dump -U {user-name} {source_db} -f {dumpfilename.sql}Brian Lau– Brian Lau2016-05-10 05:30:48 +00:00Commented May 10, 2016 at 5:30
Add a comment
|
1 Answer
You could do the following to transfer it across with pg_dump:
ssh blau08@blau08 'pg_dump -C fieldfacts' | psql template1
This way you run pg_dump on the remote server, and direct the output to your locally-running psql. This system is effective for large databases, since it doesn't create any intermediate files, and is (relatively) fast and secure. If the database is large, compressing the output and using [email protected] may improve performance (ssh -C -c [email protected] ...)