Skip to main content

Posts

Showing posts from October, 2012

Windows Pg_Dump Script

Hi , I recently developed a pg_dump windows based script, which can help us to schedule the pg_dump through pg_Agent or through windows scheduler. This script also having the backup retention policy and in any case it retain the last two consistant backups. i.e, if the current backup is successful, then it will remove the 2nd last backup from the backup location . @ECHO OFF REM pgAgent Windows Pg_Dump Script  set BIN="C:\Program Files\PostgreSQL\9.1\bin" set BACKUPLOC="C:\Dump" set LOGLOC="C:\Dump" set DATABASES=%4 set USER=%3 set PORT=%2 set DT=%date% set HOST=%1 REM DUMP MODE {CUSTOM,TAR,PLAIN} set DUMP_MODE=CUSTOM  set RETAIN_LAST_BACKUPS=2 %BIN%\psql -Atq -h %HOST% -U %USER% -p %PORT% -c "select translate(replace('%DT%','/','_'),' ','_');" postgres >_TMP set /p DT=<_TMP REM Creating Scheduled Backup %BIN%\psql -Atq -h %HOST% -U %USER% -p %PORT% -c "select replace(&