2

I opened an SQL Shell (psql) and entered my information: username, port, host, database and password.

Then the name of the database popped up like so

Testing_Database-#

Then I attempted to dump a table into a file like so

pg_dump -h BigSever -p 5432 -t customer_order > plzwork.sql 

Nothing showed up on my machine. I quickly got back

Testing_Database-#

I searched my entire computer for it then I read online to try

pg_dump -h BigSever -p 5432 -t customer_order > C:\plzwork.sql 

It didn't work either. It threw an error, so I tried another example

pg_dump -h BigSever -p 5432 -t customer_order > "C:\\plzwork.sql"

and got

Testing_Database-#

But still, it wasn't in the C drive as expected. So, I am now wondering am I supposed to get a notification of completion? If it is working, why isn't it sending it where I can find it.

Also, I tried my own personal localhost to do a dump and got the same results.

Promise Preston
  • 16,322
  • 10
  • 91
  • 108
user1778743
  • 191
  • 1
  • 6
  • 19

2 Answers2

5

If you are looking to use pg_dump, the command is meant for normal command prompt not for psql command prompt.

Go to your command line and run the pg_dump tablename dbname > filename.sql You can pwd just to make sure where you are.

Winscp the file to destination server. In the destination server,log into the psql command.

Run psql dbname < filename.sql

MrKarma4u
  • 95
  • 1
  • 10
  • 1
    Thank you so much. I don't know how I missed this detail even though I had done backups several times in the past, and I kept wondering why it was not working. – Promise Preston Aug 04 '20 at 15:04
0

If you are a Mac user:

/Applications/Postgres.app/Contents/Versions/9.6/bin/pg_dump -h BigSever -p 5432 -t customer_order > plzwork.sql

As @MrKarma4u mentioned, this has to be run from the regular command prompt (not from psql)

Anupam
  • 13,804
  • 17
  • 61
  • 90