Alex Rivera | Logout

PostgreSQL pg_dump

Asked 2012-02-21T18:13:01.507
19

I am trying to create a database backup using the command

pg_dump -U vdc(old db) | psql vdc_bak.sql(backup db);

What's wrong with the syntax here?

It tells "syntax error near pg_dump"

Edit
Report

1 Answer

44

You still don't show us the big picture, but the "syntax error" seems to indicate that you run that from within a SQL client tool (psql, pgAdmin, ...)

pg_dump and psql are commandline programs, not SQL statements.

You need to run them from the command prompt (aka shell)

Additionally the (old db) parameter is completely wrong. The database is not put into brackets for pg_dump, e.g:

pg_dump -U user1 dbname_old_db | psql -U user2 dbname_new_db

Again: you have to run this from the command prompt, not from within a SQL tool

answered 2012-02-21T19:24:09.440

Your Answer