On Thu, Nov 06, 2003 at 12:09:26 +0100,
Gerd Terlutter <gerd(at)MplusB(dot)de> wrote:
> Hi list,
> i've written a script for dumping several databases (mysql + PG), and it
> runs fine. But now i have the problem to convert it into a cron script.
> how can i run pg_dump with password? i found nothing in the manpages
> about pg login and passwords, e.g. on mysql i can use --password=xxx.
> any ideas how todo this?
In recent versions you can use a ~/.pgpass file to keep the password.
It is a bad idea to pass passwords on a command line as on most unix
like OS's the argument list can be seen by other people.
If the cron job is running on the same server as postgres, then you
can use either trust or ident authentication for connections over
domain sockets (assuming your OS supports the equivalent of getpeeruid).
ident is probably better to use, but if only trusted users have access
to the box the setup is a little simpler.
The stuff on pgpass seems to be a bit hard to find. It is documented
under libpq rather than for each application that uses libpq.
The following was copied from the 7.4 documentation:
The file .pgpass in a user's home directory is a file that can contain
passwords to be used if the connection requires a password (and no
password has been specified otherwise). This file should have lines of
the following format:
Each of the first four fields may be a literal value, or *, which
matches anything. The password field from the first line that matches
the current connection parameters will be used. (Therefore, put
more-specific entries first when you are using wildcards.) If an entry
needs to contain : or \, escape this character with \.
In response to
pgsql-php by date
|Next:||From: Christopher Kings-Lynne||Date: 2003-11-06 15:04:05|
|Subject: Re: pg_dump + cronjob|
|Previous:||From: Gerd Terlutter||Date: 2003-11-06 11:09:26|
|Subject: pg_dump + cronjob|