PostgreSQL backup

9:37 AM

PostgreSQL backup script, good for both standalone and cluster setup.
#!/bin/bash
backuppath="/data/postgresql/pgsql_backups"
now=$(date +"%Y-%m-%d")
 
if  [ -n "$(pgrep postgres)" ]
then
find $backuppath/* -mtime +2 -exec rm -f {} \;
su - postgres -c "pg_dumpall | gzip -f > $backuppath/pgbackup-$now.sql.gz"
fi

Postgres Backup Setup

Steps for Redhat servers with Postgres database.

  1. vi <backup Path>/BackupScript.sh
  2. copy and paste the attached file called fulldatabasebackup for a full database backup only
  3. chmod 755 <backup Path>/BackupScript.sh
  4. cp <backup Path>/BackupScript.sh /etc/cron.daily/BackupScript.sh

You Might Also Like

0 comments

Contact Form

Name

Email *

Message *

Translate

Wikipedia

Search results