Thread: pg_dump

pg_dump

From
"Viorel Dragomir"
Date:
Is there a way to dump all database contents using pg_dump for a custom user.
Something like:
pg_dump --user=user_name --password=password database
where user_name is any user granted to access this database with all the rights.
 
The problem is pg_dump has an option --password, but it's interactive and i need to launch the command from a php script.
 
thx.
 
Note that mysqldump has this kind of options.

Re: pg_dump

From
Frank Finner
Date:
Hi,

with PostgreSQL you can do it using the environment variables PGUSER and
PGPASSWORD for example in a shellscript like this (bash-syntax):

#!/bin/bash
export PGUSER=customer
export PGPASSWORD=sdds9087c
pg_dump mybigdatabase

or all in one line (eg as content of a system command in PHP):

PGUSER=customer PGPASSWORD=sdds9087c pg_dump mybigdatabase

mfg Frank Finner


On Wed, 16 Jul 2003 11:48:29 +0300 "Viorel Dragomir" <bigchief@vio.ro>
sat down, thought long and then wrote:

> Is there a way to dump all database contents using pg_dump for a
> custom user. Something like:
> pg_dump --user=user_name --password=password database
> where user_name is any user granted to access this database with all
> the rights.
>
> The problem is pg_dump has an option --password, but it's interactive
> and i need to launch the command from a php script.
>
> thx.
>
> Note that mysqldump has this kind of options.

Maybe, but a lot of other options are missing in that database engine.



Re: pg_dump

From
Andrew Sullivan
Date:
On Fri, Jul 25, 2003 at 10:20:38PM +0200, Frank Finner wrote:
> Hi,
>
> with PostgreSQL you can do it using the environment variables PGUSER and
> PGPASSWORD for example in a shellscript like this (bash-syntax):
  ^^^^^^^^^^

But note that that isn't safe.  If you're using >= 7.3, you can use
.pgpass instead, which is much safer.

A


--
----
Andrew Sullivan                         204-4141 Yonge Street
Liberty RMS                           Toronto, Ontario Canada
<andrew@libertyrms.info>                              M2P 2A8
                                         +1 416 646 3304 x110


Re: pg_dump

From
Frank Finner
Date:
Hi,

surely you are right. I´m still using 7.2.3 as production database, so I
have no experience with .pgpass. Where to put .pgpass if you use pg_dump
from a PHP script and the database user is not a system user?

Greetings,

Frank Finner


On Fri, 25 Jul 2003 17:17:26 -0400 Andrew Sullivan
<andrew@libertyrms.info> sat down, thought long and then wrote:

> On Fri, Jul 25, 2003 at 10:20:38PM +0200, Frank Finner wrote:
> > Hi,
> >
> > with PostgreSQL you can do it using the environment variables PGUSER
> > and PGPASSWORD for example in a shellscript like this (bash-syntax):
>   ^^^^^^^^^^
>
> But note that that isn't safe.  If you're using >= 7.3, you can use
> .pgpass instead, which is much safer.
>
> A

Re: pg_dump

From
Andrew Sullivan
Date:
On Mon, Jul 28, 2003 at 07:18:13PM +0200, Frank Finner wrote:
> Hi,
>
> surely you are right. I?m still using 7.2.3 as production database, so I
> have no experience with .pgpass. Where to put .pgpass if you use pg_dump
> from a PHP script and the database user is not a system user?

I think you need the .pgpass in the home directory of the user
running the server processing the PHP (e.g. ~apache or ~nobody or
whatever you use).  I'm not sure how well it will work, though, given
that those users typically have /bin/false as a shell.  I haven't
tested it.

A

----
Andrew Sullivan                         204-4141 Yonge Street
Liberty RMS                           Toronto, Ontario Canada
<andrew@libertyrms.info>                              M2P 2A8
                                         +1 416 646 3304 x110