#!/bin/bash umask 027 cd /tmp # set environment BACKUP_DIR=/backup/pg-backup/ HOLD_DAYS=3 cur_date=$(/bin/date +"%Y-%m-%d") # full dump postgres dbs /usr/bin/pg_dumpall | /bin/gzip > $BACKUP_DIR/$cur_date.sql.gz # cleanup find $BACKUP_DIR -maxdepth 1 -type f -ctime +$HOLD_DAYS -exec rm -rf {} +