pg_dump problem

Started by Oakleyover 25 years ago7 messagesgeneral
Jump to latest
#1Oakley
oakerz@eudoramail.com

Using postgres 7.0.2, I am trying to dump my database for archiving the current setup and information that is in it. (surprise there huh?) and when I try:

/usr/local/pgsql/bin/pg_dump -u dbname > /some_directory/dbname.dump

it wont work! It doesnt prompt me for username and passwd or anything, and still creates the dbname.dump file in the specified directory, but it has "0" size and I never return to prompt unless I hit Ctrl-C. If I leave off the redirect and have it print to STDOUT, no problems...

I have done it as myself, as I read in the docs, since the database I am trying to dump has the same name as me, but it still wont work. I have tried to do it as root *and* as postgres - neither of those work either. What exactly am I doing wrong here?

Thanks

Join 18 million Eudora users by signing up for a free Eudora Web-Mail account at http://www.eudoramail.com

#2Merlijn van der Mee
M.vanderMee@amc.uva.nl
In reply to: Oakley (#1)
Re: pg_dump problem

You should do

/usr/local/pgsql/bin/pg_dump -u dbname -f /some_directory/dbname.dump

Merlijn

Using postgres 7.0.2, I am trying to dump my database for archiving the current setup and information that is in it. (surprise there huh?) and when I try:

/usr/local/pgsql/bin/pg_dump -u dbname > /some_directory/dbname.dump

it wont work! It doesnt prompt me for username and passwd or anything, and still creates the dbname.dump file in the specified directory, but it has "0" size and I never return to prompt unless I hit Ctrl-C. If I leave off the redirect and have it print to STDOUT, no problems...

I have done it as myself, as I read in the docs, since the database I am trying to dump has the same name as me, but it still wont work. I have tried to do it as root *and* as postgres - neither of those work either. What exactly am I doing wrong here?

Thanks

Join 18 million Eudora users by signing up for a free Eudora Web-Mail account at http://www.eudoramail.com

--
Merlijn van der Mee - Bioinformatician
Academic Medical Centre - Amsterdam
Bioinformatics Laboratory
Email: M.vanderMee@amc.uva.nl tel. +31-20-5668601
-
Version: 3.1
GCS d- s+:- a- C+++ UL++ P++++ L+++ E---- W++ N o-- K- w---
O M-- V-- PS+++ PE- Y+ PGP+ t+ 5 X- R+ tv-- b+ DI-- D++
G e* h- r--- y?
--

#3Andrew Sullivan
sullivana@bpl.on.ca
In reply to: Oakley (#1)
Re: pg_dump problem

On Thu, Jul 27, 2000 at 09:53:45AM -0500, Oakley wrote:

/usr/local/pgsql/bin/pg_dump -u dbname > /some_directory/dbname.dump

it wont work! It doesnt prompt me for username and passwd or
anything, and still creates the dbname.dump file in the specified
directory, but it has "0" size and I never return to prompt unless
I hit Ctrl-C. If I leave off the redirect and have it print to
STDOUT, no problems...

If you just type the username and password after that, you'll get the
output you want. Problem is that you're redirecting all output to a
file, and that includes the username and password prompts.

In 7.x versions, this appears to be fixed using the '-f' switch:

mymachine:~$ pg_dump -u [database] -f [somefile]

A

-- 
Andrew Sullivan                                      Computer Services
<sullivana@bpl.on.ca>                        Burlington Public Library
+1 905 639 3611 x158                                   2331 New Street
                                   Burlington, Ontario, Canada L7R 1J4
#4Philip Warner
pjw@rhyme.com.au
In reply to: Oakley (#1)
Re: pg_dump problem

At 09:53 27/07/00 -0500, Oakley wrote:

Using postgres 7.0.2, I am trying to dump my database for archiving the

current setup and information that is in it. (surprise there huh?) and when
I try:

/usr/local/pgsql/bin/pg_dump -u dbname > /some_directory/dbname.dump

it wont work! It doesnt prompt me for username and passwd or anything, and

still creates the dbname.dump file in the specified directory, but it has
"0" size and I never return to prompt unless I hit Ctrl-C. If I leave off
the redirect and have it print to STDOUT, no problems...

I think that pg_dump is sending the prompts to stdout, but I am not sure.
You can get it to work by typing:

/usr/local/pgsql/bin/pg_dump -u dbname -f /some_directory/dbname.dump

----------------------------------------------------------------
Philip Warner | __---_____
Albatross Consulting Pty. Ltd. |----/ - \
(A.C.N. 008 659 498) | /(@) ______---_
Tel: (+61) 0500 83 82 81 | _________ \
Fax: (+61) 0500 83 82 82 | ___________ |
Http://www.rhyme.com.au | / \|
| --________--
PGP key available upon request, | /
and from pgp5.ai.mit.edu:11371 |/

#5Andrew Sullivan
sullivana@bpl.on.ca
In reply to: Andrew Sullivan (#3)
Re: pg_dump problem

On Thu, Jul 27, 2000 at 12:11:53PM -0400, Antoine Reid wrote:

In 7.x versions, this appears to be fixed using the '-f' switch:

mymachine:~$ pg_dump -u [database] -f [somefile]

That is absolutely correct, although we might want to have the 'Username:'
and 'Password:' prompts sent to STDERR? That would solve that
problem... It could save some people's time in finding how it works..

Why? If you do it the new way, you get the prompts that you expect,
and you don't have to redirect to a file, so you get a nice clean
dump file.

-- 
Andrew Sullivan                                      Computer Services
<sullivana@bpl.on.ca>                        Burlington Public Library
+1 905 639 3611 x158                                   2331 New Street
                                   Burlington, Ontario, Canada L7R 1J4
#6Kyle
kaf@nwlink.com
In reply to: Andrew Sullivan (#3)
Re: pg_dump problem

Andrew Sullivan wrote:
[pg_dump problem]

If you just type the username and password after that, you'll get the
output you want. Problem is that you're redirecting all output to a
file, and that includes the username and password prompts.

In 7.x versions, this appears to be fixed using the '-f' switch:

mymachine:~$ pg_dump -u [database] -f [somefile]

what if you want to pipe the output to your favorite compression
utility? I like doing a weekly:
pg_dumpall | bzip2 - > dump.bz2

-Kyle

#7Andrew Sullivan
sullivana@bpl.on.ca
In reply to: Kyle (#6)
Re: Re: pg_dump problem

On Thu, Jul 27, 2000 at 09:25:17AM -0700, Kyle wrote:

what if you want to pipe the output to your favorite compression
utility? I like doing a weekly:
pg_dumpall | bzip2 - > dump.bz2

Debian handles something similar for its nightly do.maintenance
script. You have to put the password in the cron.d/postgresql file, which
is terrible security practice, but the only way to automate this with
'password' as the authentication method on the local machine. The
script called by the cron job tests for whether the password is set,
and then passes that on to the postmaster when doing maintenance.

There is an unfortunate side effect, in that you get a daily mail
from cron with the three password prompts.

The better way to do this, I think, is to use some other
authentication method.

-- 
Andrew Sullivan                                      Computer Services
<sullivana@bpl.on.ca>                        Burlington Public Library
+1 905 639 3611 x158                                   2331 New Street
                                   Burlington, Ontario, Canada L7R 1J4