~ Bash Script to Backup Remote Postgres Databases via Cron with Password Authentication
» By Joren on Thursday 17 July 2008I have modified a bash-script to backup PostgreSQL databases, this is the original script. The modified version can be used to backup databases on a remote or local database server. Also this script does not need a trust relationship but uses a login and password. To get started you need to:
- Modify the directory and database variables to suit your needs.
- Add an entry to crontab to perform the backups nightly or whenever you wish.
- Have fun.
The script empties ~/.pgpass and writes login info for the system databases. Then it logs in and fetches an up-to-date list of databases. For every database an entry is made in ~/.pgpass and every database is backed up. The results are logged to $logfile.