导出:
/usr/bin/pg_dump -U postgres testdb > /home/app/testdb`date +%Y%m%d`.sql
cd /home/app
gzip testdb`date +%Y%m%d`.sql
导入:
day=`date +%Y%m%d`
psql <<EOF
drop database testdb;//删除原来的库
CREATE DATABASE testdb;
\p
EOF
psql -U postgres -d testdb -f /home/app/testdb${day}.sql
Be First to Comment