sign in | join about | help | sitemap
Connecting Tech Pros Worldwide
Alex's Avatar

PG_DUMP question


Question posted by: Alex (Guest) on November 12th, 2005 12:57 AM
Hi,
is ther a way to pass a password to the pg_dump command to avoid being
prompted for it.
I want to execute the dump from a perl or shell script and dont want to
open accees for the user in the pg_hba.conf

I tried
PGUSER=userid PGPASSWD=passwd pg_dump -Fc -f dump.db mydb;

Thanks
Alex




---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to Join Bytes!

3 Answers Posted
Alvaro Herrera's Avatar
Guest - n/a Posts
#2: Re: PG_DUMP question

On Tue, Dec 02, 2003 at 09:31:43AM +0900, Alex wrote:
[color=blue]
> is ther a way to pass a password to the pg_dump command to avoid being
> prompted for it.
> I want to execute the dump from a perl or shell script and dont want to
> open accees for the user in the pg_hba.conf[/color]

Use the ~/.pgpass file. It will work for any libpq program, not just
pg_dump.

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"I call it GNU/Linux. Except the GNU/ is silent." (Ben Reiter)

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Alex's Avatar
Guest - n/a Posts
#3: Re: PG_DUMP question

Thanks,
but I am looking for a way to pass the password to the command rather
than using another config or password file.
I store my config infos in an xml file.
I thought I could set the environment var as suggested on some sites but
it does not seem to be working.
Alex

Alvaro Herrera wrote:
[color=blue]
>On Tue, Dec 02, 2003 at 09:31:43AM +0900, Alex wrote:
>
>
>[color=green]
>>is ther a way to pass a password to the pg_dump command to avoid being
>>prompted for it.
>>I want to execute the dump from a perl or shell script and dont want to
>>open accees for the user in the pg_hba.conf
>>
>>[/color]
>
>Use the ~/.pgpass file. It will work for any libpq program, not just
>pg_dump.
>
>
>[/color]



---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Alvaro Herrera's Avatar
Guest - n/a Posts
#4: Re: PG_DUMP question

On Tue, Dec 02, 2003 at 05:31:45PM +0900, Alex wrote:
[color=blue]
> but I am looking for a way to pass the password to the command rather
> than using another config or password file.
> I store my config infos in an xml file.
> I thought I could set the environment var as suggested on some sites but
> it does not seem to be working.[/color]

It should work. Note though that it is called PGPASSWORD, not PGPASSWD
as your example was showing. Be sure to export it.

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"Las cosas son buenas o malas segun las hace nuestra opinión" (Lisias)

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to Join Bytes! so that your
message can get through to the mailing list cleanly

 
Not the answer you were looking for? Post your question . . .
196,830 members ready to help you find a solution.
Join Bytes.com

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 196,830 network members.
Post your question now . . .
It's fast and it's free

Popular Articles

Top Community Contributors