PostgreSQL定时备份

PostgreSQL定时备份

编写一个shell脚本,暂时命名为:pg-localhost-backup.sh,内容如下:

username=$1
database=$2
backdir=$3

currTime=`date '+%Y%m%d-%H%M%S'`

/www/server/pgsql/bin/pg_dump/pg_dump -U $username $database | gzip > $backdir/$username-$database-$currTime.zip

命令解释:该命令是备份单个数据库,并将备份输出的文本内容使用gzip进行压缩存储

 

 

 



  • 随机毒鸡汤:最好别收拾房间,当房间收拾干净时,你就是房间里唯一的垃圾。

    A close-up shot of a person coding on a laptop, focusing on the hands and screen.

THE END