首页 > 代码库 > shell脚本备份postgresql数据库个人笔记

shell脚本备份postgresql数据库个人笔记

[root@newfs tmp]# vi 2.sh

#!/bin/bash
BACKUP="/home/bak"
#RSYCN="/usr/bin/rsync"
#OPTIONS="-rlHpogDtS --delete"
DATE=`date +%Y%m%d`
LOG_FILE="/var/log/backup/backupdb_$DATE.log"
SERVER="192.168.2.31"


#1.postgresql
PG_DUMP="/usr/bin/pg_dump"
echo "$PG_DUMP -U postgres -h $SERVER mi | gzip > $BACKUP/db/sql_mi_$DATE.gz" >> $LOG_FILE
$PG_DUMP -U postgres -h $SERVER mi | gzip > $BACKUP/db/sql_mi_$DATE.gz


[root@newfs tmp]# ./2.sh

[root@newfs db]# ll
total 104
-rw-r--r-- 1 root root 103126 Aug 22 17:00 sql_mi_20140822.gz


shell脚本备份postgresql数据库个人笔记