Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 28 Oct 2005 23:06:04 -0400
From:      Francisco Reyes <lists@stringsutils.com>
To:        Pat Maddox <pergesu@gmail.com>
Cc:        FreeBSD Questions <freebsd-questions@freebsd.org>
Subject:   Re: Backing up postgresql data
Message-ID:  <4362E71C.9040803@stringsutils.com>
In-Reply-To: <810a540e0510241002l56e9e0d1ra4c4f949da4a8fb9@mail.gmail.com>
References:  <810a540e0510241002l56e9e0d1ra4c4f949da4a8fb9@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Pat Maddox wrote:

>I've got postgresql 8 running on my system, and want to do nightly
>backups of the database.
>

I recommend
1- Nightly dumpall
2- More frequent backup of databases that change often.

You can setup a script like:
#!/bin/sh
PGUSER=<user>
PGPASSWORD=<passwd>
export PGUSER
export PGPASSWORD
/usr/local/bin/pg_dumpall |/usr/bin/bzip2 -c > <backup_file>

Of course you can change it to a "sh" script. :-)

For the single DB ones you can use
#!/bin/sh
PGUSER=<user>
PGPASSWORD=<password>
export PGUSER
export PGPASSWORD

cd <backup dir>
echo Dumping database to BACKUP directory
pg_dump <db>  > db.sql
echo Making tar file
tar -cyvf `date "+%Y%m%d"`-db.tbz db.sql


Hope that helps.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4362E71C.9040803>