Re: Help automate pg_dump - Mailing list pgsql-general
| From | Devrim GUNDUZ |
|---|---|
| Subject | Re: Help automate pg_dump |
| Date | |
| Msg-id | Pine.LNX.4.44.0206181724540.6304-100000@oper.metu.edu.tr Whole thread Raw |
| In response to | Re: Help automate pg_dump (terry@greatgulfhomes.com) |
| List | pgsql-general |
Hi all,
Below is what I have written to the list previously. All you need is to
install expect to your machine, if you do not have it.
****************
1. /usr/sbin/createdbbackups.sh
pg_dump dbname_1 > dbname_1.pgdump -p 5434 -u;
pg_dump dbname_2 > dbname_2.pgdump -p 5434 -u;
...
In this file, you should write the name of the databases that you want to
get the dump of.
Let's say you have 4 databases to backup.
2. /usr/sbin/dbbackup
#!/usr/bin/expect -f
set env(SHELL) /bin/sh
set env(HOME) /usr/sbin/
spawn /usr/sbin/createdbbackups.sh
expect 'User name':
send postgres\r
expect Password:
send PostgreSQL_Passwd\r
In this file, you'll write the last four lines 4 times (assuming that you
have 4 databases in your system.) Each 4 line must correspond the
databases listed in the first file.
I mean, if dbname_1 belongs to postgres user, that write postgres and its
password on the first line. If dbname_2 belongs to (let's say) surojit
user, then write suroojit and ist password there:
expect 'User name':
send surojit\r
expect Password:
send Passwd_Of_surojit\r
At the very end of this file, add the following:
spawn /usr/sbin/movedbbackups.sh
3. /usr/sbin/movedbbackups.sh
mv dbname_1.pgdump /backup/`date '+%d-%m-%Y'`;
mv dbname_2.pgdump /backup/`date '+%d-%m-%Y'`;
...
This is for moving the dumps in a daily directory.
(TO create the directory, you could use
cd /backup;
mkdir `date '+%d-%m-%Y'`
)
***************************
Regards,
Devrim
On Tue, 18 Jun 2002 terry@greatgulfhomes.com wrote:
> Hmmm.
>
> Please let the list know if you get a solution, I am about to go to 7.2 on
> my production machines but that could be a show stopper if the cron job
> cannot automatically back it up anymore.
>
> Terry Fielder
> Network Engineer
> Great Gulf Homes / Ashton Woods Homes
> terry@greatgulfhomes.com
>
> > -----Original Message-----
> > From: pgsql-general-owner@postgresql.org
> > [mailto:pgsql-general-owner@postgresql.org]On Behalf Of
> > nothanks@nowhere.com
> > Sent: Monday, June 17, 2002 10:01 PM
> > To: pgsql-general@postgresql.org
> > Subject: [GENERAL] Help automate pg_dump
> >
> >
> > We just upgraded from 7.1.3 to 7.2.1 and are at a loss on how to
> > script the pg_dump routine. We use this tool for backup, but can not
> > get around the requirement for username/password to be interactive.
> >
> > We require login from the localhost, and can not revert to trusted
> > connections.
> >
> > If the username/password must be interactive, how can I script backup
> > of the server?
> >
> > Evan,
> >
> > ---------------------------(end of
> > broadcast)---------------------------
> > TIP 3: if posting/reading through Usenet, please send an appropriate
> > subscribe-nomail command to majordomo@postgresql.org so that your
> > message can get through to the mailing list cleanly
> >
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly
>
--
Devrim GUNDUZ
devrim@oper.metu.edu.tr
devrim.gunduz@linux.org.tr
Web : http://devrim.oper.metu.edu.tr
-------------------------------------
pgsql-general by date: