Exemplo de script de backup POSTGRES com 7ZIP

SCRIPT DE BACKUP
@echo off
for /f “tokens=1-4 delims=/ ” %%i in (“%date%”) do (
set dow=%%i
set day=%%j
set month=%%k
set year=%%l
)
set datestr=%year%_%month%_%day%_%dow%
echo datestr is %datestr%

rem Define a variável horario com o valor da hora
set horario=%time%
set hh=%horario:~0,2%
set mm=%horario:~3,2%
set ss=%horario:~6,2%
set hora=%hh%_%mm%_%ss%

set datestr=%datestr%_%hora%

set BACKUP_FILE=”C:BKPALLWPS%datestr%.sql”
set EXEPGDUMP=”C:Program Files (x86)PostgreSQL8.4binpg_dumpall.exe”
echo backup file name is %BACKUP_FILE%

echo on

SET PGPASSWORD=*******

%EXEPGDUMP% –host localhost –port 5432 –username postgres –verbose –file %BACKUP_FILE%

“C:BKPALL7za.exe” u -t7z -mx=9 -ms=off -r -ssw C:BKPALLWPS%datestr%.7z %BACKUP_FILE%