Search Postgresql Archives

Re: pg_dump shell script with ~/.pgpass

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 27 Jan 2005, Richard Huxton wrote:

MargaretGillon@xxxxxxxxxxxxxx wrote:

[snip]

I need to create a shell script for cron.daily to run that will do pg_dump
for my database. I am using Redhat 9 and Postgresql v7.3.4.  Currently when
I run the dump manually the command I use is

#pg_dump -u -C -D -f /tmp/owl.sql owl

What should the command look like using ~/.pgpass ?

Well, from cron, I'd add an explicit username "-U username" and then in your .pgpass add the host/port/db/user/password as described in the manuals (client interfaces/libc/files).

Personally I _hate_ having passwords in files, and avoid it whenever possible. [1] It's another instance that I have to change when the password expires; and [B] it's a possible avenue for a security failure (or, at least requires real thought and attention to avoid turning into a security problem).

What I do instead is have the cron listing run a simple script which uses su :

	su --command="INSERT YOUR PG COMMAND HERE" $PGNAME

where PGNAME has previously been set to, for example, 'postgres'.
This script can only be run by root (or the su will fail); and if run
by root, and the PGNAME is postgres, no additional password will be
needed for DB admin.

[how to accomplish this in WinXX I have no idea]

HTH,

	-frank

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

http://www.postgresql.org/docs/faq

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux