Re: pg_dump + cronjob

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Gerd Terlutter <gerd(at)MplusB(dot)de>
Cc: pgsql-php(at)postgresql(dot)org
Subject: Re: pg_dump + cronjob
Date: 2003-11-06 15:00:51
Message-ID: 20031106150051.GC18854@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-php

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:
hostname:port:database:username:password

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

Browse pgsql-php by date

  From Date Subject
Next Message Christopher Kings-Lynne 2003-11-06 15:04:05 Re: pg_dump + cronjob
Previous Message Gerd Terlutter 2003-11-06 11:09:26 pg_dump + cronjob