5

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
  • 24,334
  • 12
  • 145
  • 143
user1778743
  • 333
  • 2
  • 7
  • 19
  • 3
    `pg_dump` is **not** a SQL or `psql` command. You run that on the command line of your _operating system_ e.g. `cmd.exe` –  Oct 04 '16 at 20:26
  • Related: http://stackoverflow.com/q/13321005/330315 –  Oct 04 '16 at 20:28
  • ok im sorry first i was told it wasnt an sql command so i did it with psql. now i shouldnt use cmd.exe cause i loggin cia command prompt. pg_dump -h BigSever -p 5432 -t customer_order > plzwork.sql in command. and i get access denied – user1778743 Oct 05 '16 at 15:48

3 Answers3

10

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
  • 144
  • 2
  • 13
  • 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
1

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
  • 14,950
  • 19
  • 67
  • 94
0

when running that terminal command you should identify a output file with ">" plus the file name "result.txt" and ensure your pathing is correct

it should look like this

pg_dump -h BigSever -p 5432 -t customer_order > "/path/to/file/plzwork.sql"

user1778743
  • 333
  • 2
  • 7
  • 19