@echo off
set pgsql_path=d:"Program Files"PostgreSQL9.3in //安装目录
set database=postgres //数据库名
set server=localhost //服务器地址
set post=5432 //端口号
set username=postgres //用户名
set date_string=%date:~0,4%_%date:~5,2%_%date:~8,2% //日期
set time_string=%time:~0,2%_%time:~3,2%_%time:~6,2% //时间
set back_path=d:pgsqldatabackup //备份文件存放路径
if not exist %back_path% md %back_path%
set file_string=%back_path%data_%date_string%_%time_string%
set file=%file_string%.sql //文件名
%pgsql_path%pg_dump.exe -h%server% -p%post% -U%username% %database%>%file% //备份(注:pg_dump.exe 后面可追加很多参数,如果要用到可在dos命令中输入 pg_dump --help 查找,前提是配置好postgresql的环境变量)
pause
(注:如果要定时,压缩和上传ftp,可参照我前面写的oracle数据库的备份)