Compare with Previous | Blame | View Log
#!/bin/bash####################################### PostgreSQL Backup Script#===================================## Backs up the specified database to# a file with the same name as the db# and the data appended to the end#####################################if [ $# != 1 ]; thenecho ""echo " PostgreSQL Backup Script"echo " ------------------------"echo "Backs up Postgresql DB to file"echo ""echo "Usage: $0 <database to backup> "echo ""exitfi#Define the backup directory, and target filename.BACKUP_DIR="/tmp/"FILENAME="$1"`eval date +%Y%m%d`#Perform the backup.pg_dump -f $BACKUP_DIR$FILENAME.sql -D -h localhost $1#Change to the backup dircd $BACKUP_DIR#Tar and Gzip the backuptar -czf $BACKUP_DIR$FILENAME.tar.gz $FILENAME.sql#Remove the plain text version.rm -rf $FILENAME.sql