Re: How to create nightly backups in Linux

From: Steve Wampler <swampler(at)noao(dot)edu>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: How to create nightly backups in Linux
Date: 2006-09-27 18:28:51
Message-ID: 451AC2E3.3040305@noao.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Andrus wrote:
> I'm bit new to Linux. I'm using white-box linux and Postgres 8.1.4
> How to create backups of database with unique name in every night ?
> Is there some script sample which can be called from /etc/crontab ?

I use the following Z-shell script. Rewriting to bash should be
trivial (probably no changes after the first line).
Note that this differs from yours in that it uses pg_dumpall
and dumps everything. You would want to change that...

-----------------------------------------------
#!/bin/zsh

# We prefer backing up to the SAN, but use the local
# disk as a fallback if the SAN isn't available.
backupdir=/u3/SolisDBbackups
if [ -d /mnt/san/SOLIS-files/db_backups ]; then
backupdir=/mnt/san/SOLIS-files/db_backups
fi

backupdate=$(date --iso-8601=minutes)
backupfile=${backupdir}/${backupdate}.dbtxt
echo "Backing up SOLIS databases to ${backupfile}.gz"
date
pg_dumpall -c | gzip >${backupfile}.gz
echo "Backup of SOLIS databases to ${backupfile}.gz done."
date
exit 0
--------------------------------------------

The crontab entry is:
-------------------------------------------
45 21 * * * /u3/SolisDBbackups/fullDump.zsh
-------------------------------------------

Hope this helps.
--
Steve Wampler -- swampler(at)noao(dot)edu
The gods that smiled on your birth are now laughing out loud.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Scott Marlowe 2006-09-27 18:55:44 Re: change the order of FROM selection to make query work
Previous Message Andrus 2006-09-27 18:17:24 How to create nightly backups in Linux