Thread: pg_dump + cronjob

pg_dump + cronjob

From
Gerd Terlutter
Date:
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?

Greetings,
Gerd
--
--------------------------------------------------------
# Gerd Terlutter         | Mueller+Blanck Software GmbH #
# Gutenbergring 38       | D-22848 Norderstedt          #
# office:+49 40 500 171-1| fax:+49 40 500 171-71        #
--------------------------------------------------------



Re: pg_dump + cronjob

From
Bruno Wolff III
Date:
On Thu, Nov 06, 2003 at 12:09:26 +0100,
  Gerd Terlutter <gerd@MplusB.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 \.

Re: pg_dump + cronjob

From
Christopher Kings-Lynne
Date:
export PGPASSWORD=mypassword

Chris

On Thu, 6 Nov 2003, Gerd Terlutter 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?
>
> Greetings,
> Gerd
> --
> --------------------------------------------------------
> # Gerd Terlutter         | Mueller+Blanck Software GmbH #
> # Gutenbergring 38       | D-22848 Norderstedt          #
> # office:+49 40 500 171-1| fax:+49 40 500 171-71        #
> --------------------------------------------------------
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>