我正在为我的 PostgreSQL 数据库创建每日备份计划程序,为此我安装了 Pg-agent 并创建了作业计划程序。我创建了一个 .bat 文件并在其中编写了运行良好的脚本。当我从命令提示符执行 .bat bat 文件时,我想要什么,它要求输入密码,所以我想删除它并执行 .bat 文件而不询问密码。
@echo Backup database %PG_PATH%%PG_FILENAME%
@echo off
SET PG_BIN="C:\Program Files\PostgreSQL\9.5\bin\pg_dump.exe"
SET PG_HOST=localhost
SET PG_PORT=5432
SET PG_DATABASE=postgres
SET PG_USER=postgres
SET PG_PASSWORD=postgres
SET PG_PATH=C:\OEM
SET FECHAYHORA=%date:/=%-%time:-0,8%
SET FECHAYHORA=%FECHAYHORA::=-%
SET FECHAYHORA=%FECHAYHORA: =0%
SET PG_FILENAME=zerodefect_%time:~0,2%%time:~3,2%%time:~6,2%_%date:~-10,2%%date:~-7,2%%date:~-4,4%.sql
%PG_BIN% -h %PG_HOST% -p %PG_PORT% -U %PG_USER% %PG_DATABASE% > %PG_FILENAME%
@echo Backup Taken Complete %PG_PATH%%PG_FILENAME%