From: Preston <unsane@idl.com.au>
To: Bruce Momjian <pgman@candle.pha.pa.us>
Cc: Panchal, Ritesh <RPanchal@netopia.com>
Cc: 'pgsql-admin@postgresql.org' <pgsql-admin@postgresql.org>
Subject: Re: Database backup
Date: Thu, 13 Feb 2003 08:37:52 +1100 (EST)
Message-ID: <1045085872.3e4abeb063628@mail.idl.net.au> (raw)
In-Reply-To: <200302122127.h1CLRF120096@candle.pha.pa.us>
References: <200302122127.h1CLRF120096@candle.pha.pa.us>
Hi all,
> 7.3.2 has .pgpass where you can place the password.
That's a nice feature - haven't read up much on the 7.3 series as yet. It will
certainly remove my reliance on kludgy expect scripts to automate backups and
refreshes...
> Panchal, Ritesh wrote:
> > Hi,
> > I am trying to automate my backups using pg_dump. However, I am not
> > able to pass the password to the command. Has anybody sucessfully done
> > automated backup thru scripts?
> >
> > Thank you for your comments and suggestions.
As above - I've used "expect" in the past with success. Stored in a secure
directory that only postgres will have access to (with of course the exception
of root...) I have a "dump_prodDB" script which looks like the following:
========================== expect script ===============================
#!/usr/bin/expect
spawn pg_dump prodDB -f /var/lib/pgsql/tmp/prodDB.dump -U backup_user
set timeout -1
expect "Password:"
send "s3cr3tpa55w0rd\r"
expect eof
========================== expect script ===============================
(Where "s3cr3tpa55w0rd" is the appropriate password string or md5 password for
the backup user...)
This is in turn called by the primary backup script, which backs up all the
databases on the system but for those databases requiring passwords invokes the
appropriate script. Since I have only one database requiring a password I didn't
bother to make the script generic by database name but that's relatively easy.
The script that calls this then does a bzip2 on the database backup. This is
called as part of a Legato NetWorker savepnpc process, which then writes it off
to tape as part of the filesystem backup...
As I said, it's a kludge. But it works for what I need it to do :)
Cheers,
-Preston.
--
Oops.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: unsane@idl.com.au, pgman@candle.pha.pa.us, RPanchal@netopia.com
Subject: Re: Database backup
In-Reply-To: <1045085872.3e4abeb063628@mail.idl.net.au>
References: <200302122127.h1CLRF120096@candle.pha.pa.us> <1045085872.3e4abeb063628@mail.idl.net.au>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox