Skip site navigation (1) Skip section navigation (2)

Re: [ADMIN] Mail For database backup and restore

From: Palle Girgensohn <girgen(at)partitur(dot)se>
To: Vikrant Rathore <vikrant(at)chemquick(dot)com>
Cc: pgsql-admin(at)postgreSQL(dot)org
Subject: Re: [ADMIN] Mail For database backup and restore
Date: 1998-10-20 00:53:15
Message-ID: 362BDEFB.17CFB5C1@partitur.se (view raw or flat)
Thread:
Lists: 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(at)chemquick(dot)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 {} \;

In response to

pgsql-admin by date

Next:From: pete collinsDate: 1998-10-20 12:16:18
Subject: newbie question
Previous:From: Gilley, Charles H.Date: 1998-10-19 22:22:10
Subject: 6.3.2 built, installed and running on Solaris 2.5.1.... recap

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group