Following script can be used to get the Postgres backup with .backup extension
@echo off
for /f "tokens=1-4 delims=/ " %%i in ("%date%") do (
set dow=%%i
set month=%%j
set day=%%k
set year=%%l
)
set datestr=%day%_%month%_%year%
echo datestr is %datestr%
set BACKUP_FILE=DBNAME_%datestr%BACKUP_FILE=C:\Users\slan\Desktop\backup_test\DBNAME_%datestr%.backup
echo backup file name is %BACKUP_FILE%
SET PGPASSWORD=YOUR_PASSWORD
echo on
bin\pg_dump -i -h localhost -p 5432 -U postgres -F c -b -v -f %BACKUP_FILE% YOUR_DB_NAME
you must have PostgreSQL's bin folder(Ex. C:\PostgreSQL\9.4\bin) along with this script otherwise this will not work as you expect
To schedule the task you can use Windows Task scheduler, here is an example for how to ?? - How to schedule a Batch File to run automatically in Windows 10 / 8 / 7