Re: pg_dump shell script with ~/.pgpass

From: Richard Huxton <dev(at)archonet(dot)com>
To: MargaretGillon(at)chromalloy(dot)com
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: pg_dump shell script with ~/.pgpass
Date: 2005-01-27 17:22:30
Message-ID: 41F92356.5040906@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

MargaretGillon(at)chromalloy(dot)com wrote:
> I posted the message below on 1/15/05 and haven't received a reply yet.
> Should I be asking this question on a different list?

This is probably the right list - your message may have been missed
though, there can be a lot of traffic.
>
> 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).

> My other question... Is cron.daily is being run by root? If so would I need
> to put the .pgpass file in root's home directory?

Yes and yes. Also, make sure you chmod the file as described in the manual.
The alternative would be to set up a crontab for another user, and place
the .pgpass in their home-dir.

> I only have two postgresql users right now, myself and postgres. On the
> redhat server I have only two users, myself and root, there is no user
> postgres.

Are you sure? There are almost certainly dozens of users in /etc/passwd
and if you installed by RPM then there *will* be a user postgres. That's
not to say you can just login as them though - they might have their
shell disabled.

--
Richard Huxton
Archonet Ltd

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bruno Almeida do Lago 2005-01-27 17:32:38 Oracle and PostgreSQL
Previous Message Alvaro Herrera 2005-01-27 17:13:05 Re: pg_dump shell script with ~/.pgpass