Per favore, ricontrolla il copione, lo faccio al volo. Non ricordo quale sia la -w su pg_dump. In questo modo otterrai un file per ogni db. E come suggerimento, usa \ invece / quando parli dei percorsi delle cartelle su Windows Scusa il mio inglese.
@echo off
set BASELOG=LOG
set BACKUPDIR=C:/postgres/backups/
set BACKUPDIR2=C:\postgres\backups
set PGHOST=localhost
set PGUSER=postgres
set PGBIN="C:/Program Files/PostgreSQL/9.3/bin/"
set FILELOG=log.txt
set BACKUPDIRDATE="%BACKUPDIR%%date%/"
for /f "tokens=1-4 delims=/ " %%i in ("%date%") do (
set dow=%%i
set month=%%j
set day=%%k
set year=%%l
)
if not exist %BACKUPDIRDATE% mkdir %BACKUPDIRDATE%
(
if exist dbs.lst del dbs.lst
psql -h %PGHOST% -p 5432 -U %PGUSER% -c "SELECT datname FROM pg_database WHERE datistemplate = false;" -o "dbs.lst"
for /f %%a IN (dbs.lst) DO (
echo Backup start %date% %time%
%PGBIN%pg_dump -w -i -h %PGHOST% -U %PGUSER% -F c -b -v -f "%BACKUPDIRDATE%-%%a.compressed" %%a
echo End of backup %BASELOG%
)
FORFILES /p %BACKUPDIR2% /s /D -7 /C "cmd /c rd /S /Q @path"
echo Files are deleted
)>> %BACKUPDIRDATE%%FILELOG% 2>&1