pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedRe(2): Crontab and PostgreSQL Backup
3+ messages / 3 participants
[nested] [flat]
* Re(2): Crontab and PostgreSQL Backup
@ 2000-10-06 11:48 pgsql-admin <pgsql-admin@fc.emc.com.ph>
0 siblings, 1 reply; 3+ messages in thread
From: pgsql-admin @ 2000-10-06 11:48 UTC (permalink / raw)
To: pgsql-admin
you can also try this:
#!/bin/sh
# Backing up each database...
pg_dumpall -o | bzip2 > /var/lib/pgsql/backups/pgdumpall_`date
"+%Y%m%d"`.bz2
# Removing backups of last seven days...
find /var/lib/pgsql/backups -mtime +7 -exec rm -f {} \;
Sherwin
gunix@telia.com writes:
>>I use PostgreSQL version 7.0.2 for Linux Conectiva 5.1 Server, and I
>> would like to know how do I do to configure and start the PostgreSQL's
>backup
>> and restore
>>using crontab?
>
>restore with crontab???
>
>Anyway.
>Put a line in crontab like:
>3 5 * * * /script/backdb.sh
>
>and the script /script/backdb.sh
>could then look like:
>
>#!/bin/bash
>DATE=`date +%Y%m%d`
>/usr/pgsql/bin/pg_dump databas > /tmp/dump.$DATE
>
>then you have a file in /tmp/dump.$DATE that you could put on tape or
>whatever
>you use. Use pg_dumpall if you want all databases.
>You might want to consider making a backup of the files (for example
>pg_hba.conf) in PGDATA directory. Read the man page for details about
>OID's.
>
>Good luck.
>Gunnar.
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Re(2): Crontab and PostgreSQL Backup
@ 2000-10-06 12:07 Ragnar Kjørstad <postgres@ragnark.vestdata.no>
parent: pgsql-admin <pgsql-admin@fc.emc.com.ph>
0 siblings, 1 reply; 3+ messages in thread
From: Ragnar Kjørstad @ 2000-10-06 12:07 UTC (permalink / raw)
To: pgsql-admin <pgsql-admin@fc.emc.com.ph>; +Cc: pgsql-admin
On Fri, Oct 06, 2000 at 07:48:03PM +0800, pgsql-admin wrote:
> you can also try this:
or:
#!/bin/bash
PREFIX=/directory
DATABASE=db
rm -f $PREFIX.last
pg_dump -d $DATABASE -f $PREFIX.last
ln -f $PREFIX.last $PREFIX.hour.`date +%H`
ln -f $PREFIX.last $PREFIX.day.`date +%d`
ln -f $PREFIX.last $PREFIX.month.`date +%Y%m`
Run this every hour, and $PREFIX will contain backups for every hour for
the last day, every day for the last month and one backup for every
month.
--
Ragnar Kjørstad
Modus Media
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Re(2): Crontab and PostgreSQL Backup
@ 2000-10-07 15:44 Jeff MacDonald <jeff@pgsql.com>
parent: Ragnar Kjørstad <postgres@ragnark.vestdata.no>
0 siblings, 0 replies; 3+ messages in thread
From: Jeff MacDonald @ 2000-10-07 15:44 UTC (permalink / raw)
To: Ragnar Kjørstad <postgres@ragnark.vestdata.no>; +Cc: pgsql-admin <pgsql-admin@fc.emc.com.ph>; pgsql-admin
here's a backup script we use
#!/bin/sh
cd /pgsql/backups
if [ ! -d $1 ]
then
mkdir $1
fi
cd $1
for i in `ls $2 | egrep -v "template1|udmsearch"`
do
/usr/local/bin/rotate_files.pl $i 7
/pgsql/bin/pg_dump -p $1 -h localhost $i > $i.0
gzip -f $i.0 &
done
On Fri, 6 Oct 2000, [iso-8859-1] Ragnar Kjørstad wrote:
> On Fri, Oct 06, 2000 at 07:48:03PM +0800, pgsql-admin wrote:
> > you can also try this:
>
> or:
>
> #!/bin/bash
> PREFIX=/directory
> DATABASE=db
> rm -f $PREFIX.last
> pg_dump -d $DATABASE -f $PREFIX.last
> ln -f $PREFIX.last $PREFIX.hour.`date +%H`
> ln -f $PREFIX.last $PREFIX.day.`date +%d`
> ln -f $PREFIX.last $PREFIX.month.`date +%Y%m`
>
> Run this every hour, and $PREFIX will contain backups for every hour for
> the last day, every day for the last month and one backup for every
> month.
>
>
>
Jeff MacDonald,
-----------------------------------------------------
PostgreSQL Inc | Hub.Org Networking Services
jeff@pgsql.com | jeff@hub.org
www.pgsql.com | www.hub.org
1-902-542-0713 | 1-902-542-3657
-----------------------------------------------------
Facsimile : 1 902 542 5386
IRC Nick : bignose
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2000-10-07 15:44 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-10-06 11:48 Re(2): Crontab and PostgreSQL Backup pgsql-admin <pgsql-admin@fc.emc.com.ph>
2000-10-06 12:07 ` Ragnar Kjørstad <postgres@ragnark.vestdata.no>
2000-10-07 15:44 ` Jeff MacDonald <jeff@pgsql.com>
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