LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Newbie to Postgres (https://www.linuxquestions.org/questions/linux-server-73/newbie-to-postgres-925410/)

glennbtn 01-24-2012 03:50 AM

Newbie to Postgres
 
Hi All

I have been given a postgres machine to look after. I need to get a backup sorted out and trying to use pg_dump.

When every I try to use it I get an error even with just the basics of pg_dump databasename. We are running 9.1 error below

ERROR: syntax error at or near "pg_dump"
LINE 1: pg_dump testdatabase

Any advise would be good. Thanks

MartinStrec 01-24-2012 04:08 AM

Run full vacuum before dumping.

Check if your pg_dump is the same or higher version than DB is running!

catkin 01-24-2012 04:15 AM

Are you running pg_dump from a command prompt or a script? Either way what are the exact commands being used?

glennbtn 01-24-2012 04:20 AM

It's a new build of postgres so would guess it's the correct verion of pg_dump but the pg_dump --version doe snot display any info.

glennbtn 01-24-2012 04:22 AM

I am running it from the command prompt before I get as far as scripting it. I have been on the postgressql manual and tried almost every option so the question is more of what have I not tried.

MartinStrec 01-24-2012 04:30 AM

When you built postgres from source. PG_DUMP is in /usr/local/pgsql/bin/pg_dump or anywhere you've been setting in --prefix. Be aware, /usr/bin/pg_dump can contain different version, that has been installed with your system.

If 'pg_dump --version' doesn't show anything then something is really wrong.

Type the full path when you are running pg_dump.

catkin 01-24-2012 04:30 AM

Can you post the command that resulted in
Code:

ERROR: syntax error at or near "pg_dump"
LINE 1: pg_dump testdatabase


glennbtn 01-24-2012 04:40 AM

Ok my pg_dump seems to be located in /usr/pgsql-9.1/bin. When run from this location with the --version I still get nothing.

I get the
ERROR: syntax error at or near "pg_dump"
LINE 1: pg_dump testdatabase

when trying to run the most basic of commands pg_dump customers;
or pg_dump customers -U data;
or pg_dump -U data customers;

Thanks

catkin 01-24-2012 04:57 AM

The error messages suggest that pg_dump is a script (and they are not bash error messages).

What is pg_dump? On Debian Squeeze it is symlinked to a Perl script:
Code:

docoll@CW8vDS:~$ type pg_dump
pg_dump is /usr/bin/pg_dump
docoll@CW8vDS:~$ file /usr/bin/pg_dump
/usr/bin/pg_dump: symbolic link to `../share/postgresql-common/pg_wrapper'
docoll@CW8vDS:~$ file /usr/share/postgresql-common/pg_wrapper
/usr/share/postgresql-common/pg_wrapper: a /usr/bin/perl -w script text executable


glennbtn 01-24-2012 05:06 AM

Thanks catkin, although I am a little confused by that.

I am not running any script just
su postgres
psql
pg_dump database;

Hope this helps

catkin 01-24-2012 05:24 AM

Sorry to confuse. The bash type builtin command and the file binary command can be used as shown at the command prompt to determine what is run in response to using a particular command at the command prompt.

I did not know it was possible to run pg_dump from within an interactive PostgreSQL session. Maybe it's not and hence the error message.

What happens if you try running it at the command prompt?

glennbtn 01-24-2012 11:24 AM

Ok looks like I had the wrong end of the stick.

Trying from the command line seems to give me results.

Thanks for the advise catkin


All times are GMT -5. The time now is 12:41 PM.