LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 01-24-2012, 03:50 AM   #1
glennbtn
Member
 
Registered: Dec 2009
Posts: 87

Rep: Reputation: 18
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
 
Old 01-24-2012, 04:08 AM   #2
MartinStrec
Member
 
Registered: Jan 2012
Location: Czech
Distribution: Fedora, RHEL, Ubuntu, Mint
Posts: 110

Rep: Reputation: 13
Run full vacuum before dumping.

Check if your pg_dump is the same or higher version than DB is running!
 
Old 01-24-2012, 04:15 AM   #3
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,533
Blog Entries: 28

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
Are you running pg_dump from a command prompt or a script? Either way what are the exact commands being used?
 
Old 01-24-2012, 04:20 AM   #4
glennbtn
Member
 
Registered: Dec 2009
Posts: 87

Original Poster
Rep: Reputation: 18
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.
 
Old 01-24-2012, 04:22 AM   #5
glennbtn
Member
 
Registered: Dec 2009
Posts: 87

Original Poster
Rep: Reputation: 18
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.
 
Old 01-24-2012, 04:30 AM   #6
MartinStrec
Member
 
Registered: Jan 2012
Location: Czech
Distribution: Fedora, RHEL, Ubuntu, Mint
Posts: 110

Rep: Reputation: 13
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.
 
Old 01-24-2012, 04:30 AM   #7
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,533
Blog Entries: 28

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
Can you post the command that resulted in
Code:
ERROR: syntax error at or near "pg_dump"
LINE 1: pg_dump testdatabase
 
Old 01-24-2012, 04:40 AM   #8
glennbtn
Member
 
Registered: Dec 2009
Posts: 87

Original Poster
Rep: Reputation: 18
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
 
Old 01-24-2012, 04:57 AM   #9
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,533
Blog Entries: 28

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
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
 
Old 01-24-2012, 05:06 AM   #10
glennbtn
Member
 
Registered: Dec 2009
Posts: 87

Original Poster
Rep: Reputation: 18
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
 
Old 01-24-2012, 05:24 AM   #11
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,533
Blog Entries: 28

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
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?
 
1 members found this post helpful.
Old 01-24-2012, 11:24 AM   #12
glennbtn
Member
 
Registered: Dec 2009
Posts: 87

Original Poster
Rep: Reputation: 18
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
postgres - performance sridhar_dct3 Linux - Software 12 04-09-2008 05:45 AM
Changes in postgres without restarting postgres venki Linux - General 3 07-19-2007 01:06 AM
Can't start nor stop Postgres (NEWBIE) pramirez Linux - Software 1 06-27-2005 11:05 PM
Postgres Hiper1 Linux - Newbie 8 04-10-2005 05:43 PM
Installing Postgres 7.3 Hiper1 Linux - Software 0 12-01-2004 01:38 AM


All times are GMT -5. The time now is 08:11 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration