This script creates backups for PostgreSQL. It creates two kind of backup:
- full backup (dumpall) to easy restore the serveur
- by database (pg_dump). Only desired databases are considered.
There is three levels of rotation.
- n files rotation (dumpall.1, dumpall.2, .., dumpall.n)
- daily rotation, save one backup a day (dumpall.Mon, dumpall.Thu, ...)
- monthly rotation, save one backup a month (dumpall.Jan, dumpall.Fev, ...)
This script is supposed to be run as cron thus two environnement variables are needed :
$BACKUP_DIRdirectory for backup files (ex:/opt/local/backups)$BACKUP_DATABASESdatabase names (ex:"postgres mybase yourbase")
Download: backup-postgresql.sh