Discussion:
using PGPASSWORD environment variable
James Hall
2003-02-20 20:54:28 UTC
Permalink
I am trying to write a [perl] script to automate database backups. PG
requests the password every time I connect to a database. It was suggested
that I "use PGPASSWORD environment variable, just set it before you execute
pg_dumpall".


I have not been able to find any examples to show how to use the PGPASSWORD
variable in a script.

Can someone please post an example or 2?

TIA,
-jim

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html
Andrew Sullivan
2003-02-20 22:20:28 UTC
Permalink
Post by James Hall
I am trying to write a [perl] script to automate database backups. PG
requests the password every time I connect to a database. It was suggested
that I "use PGPASSWORD environment variable, just set it before you execute
pg_dumpall".
If you are using pg 7.3, store the password in the .pgpass file in
the home directory of the user instead. It's safer. Keep in mind
that the environment variable might be exposed to others logged into
the machine. (If no-one else logs into the machine, why not use
trust for local users?)

But if you must use it, you can just set it at the beginning of the
script:

PGPASSWORD=[yourpasswordhere]
/path/to/pg_dumpall

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


---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ***@postgresql.org so that your
message can get through to the mailing list cleanly
Loading...