Re: [ADMIN] Mail For database backup and restore - Mailing list pgsql-admin

From Palle Girgensohn
Subject Re: [ADMIN] Mail For database backup and restore
Date
Msg-id 362BDEFB.17CFB5C1@partitur.se
Whole thread Raw
In response to Mail For database backup and restore  (Vikrant Rathore <vikrant@chemquick.com>)
List pgsql-admin
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 {} \;

pgsql-admin by date:

Previous
From: "Gilley, Charles H."
Date:
Subject: 6.3.2 built, installed and running on Solaris 2.5.1.... recap
Next
From: pete collins
Date:
Subject: newbie question