Vikrant Rathore wrote:
>
> I would like to have a help that how can i take the backup and restore the
> database of postgres on a daily basis.
> Vikrant Rathore
>
> Neuronet
> neuronet@chemquick.com
Do you mean that you want to restore the database on a daily basis? Why?
Here's a script to save a backup of every last seven days. Run it from
cron every night or so. Don't forget to mkdir /usr/local/pgsql/backups.
#!/bin/sh
#Must be run as user pgsql
#
# run from daily.local as
# if [ -f /etc/daily.pgsql ]; then
# echo "Working on PostgreSQL"
# su -l pgsql -c daily.pgsql
# fi
echo "Backing up..."
/usr/local/pgsql/bin/pg_dumpall \
| gzip > /usr/local/pgsql/backups/pgdumpall_`date "+%Y%m%d"`.gz
echo "Vacuuming..."
for db in /usr/local/pgsql/data/base/*
do
echo ""
echo `basename $db`
/usr/local/pgsql/bin/psql -c vacuum `basename $db`
done
echo "Removing old backups..."
find /usr/local/pgsql/backups -mtime +7 -exec rm -f {} \;