版本
postgre数据库
pgadmin4
@echo off
for /f "tokens=1-4 delims=/ " %%i in ("%date%") do (
set year=%%i
set month=%%j
set day=%%k
set dow=%%l
)
set datestr=%year%_%month%_%day%
echo datestr is %datestr%
SET SAVEPATH=D:\java\test\
SET PGPATH=D:\java\postgresql\bin\
SET PGUSER=postgres
SET PGPASSWORD=123456
SET PGDB=rydw
set BACKUP_FILE=%SAVEPATH%%PGDB%_%datestr%.backup
echo backup file is %BACKUP_FILE%
echo on
D:
%PGPATH%pg_dump -h localhost -p 5432 -U %PGUSER% -F c -b -v -f %BACKUP_FILE% %PGDB%
@echo Backup Completed.
@echo Backup File: %BACKUP_FILE%
forfiles /p %SAVEPATH% /m *.backup /d -30 /c "cmd /c del @path"