pg_dump using MS-DOS BAT file

Поиск
Список
Период
Сортировка
Искать

pg_dump using MS-DOS BAT file

От:
Richard Broersma Jr <rabroersma@yahoo.com>
Дата:
Creating shell scripts and cron jobs are pretty easy tasks in *nix.  I wanted to attach a sample
BAT file script for anyone that is enterested in get something similar to work under windows. 
Comments are welcome.

Copy this text below into you own  bat file and then create a new "scheduled job"
by:

open "Control Panel"
open "Scheduled Tasks"
open "Add Scheduled Tasks"
Browse to where you saved you bat file.
Configure a the schedule and how many time a day you would like your db dumped.

I didn't attach my bat file to this email since I expect most email filters would balk at a bat
file.  Let me know what you think.

Regards,
Richard Broersma Jr.

------------------------------------------------------------------------

REM Backup BAT file script begins here

REM Set these variables to what is appropriate for your system

SET PGPATH="C:\Program Files\PostgreSQL\8.2rc1\bin\"
SET SVPATH="O:\02U20410 Rule 1105\Engr\Controls\Instrument Index\db_backup\"
SET ALTPTH="C:\Documents and Settings\BroersR\My Documents\db_backupalt\"
SET PRJDB=proj02u20411
SET DBUSR=postgres


REM This is an ugly solution to get a timestamp for the newly created
REM dump file.

FOR /F "TOKENS=2,3,4 DELIMS=/ " %%i IN ('DATE /T') DO SET d=%%k-%%i-%%j
FOR /F "TOKENS=1,2,3 DELIMS=: " %%i IN ('TIME /T') DO SET t=%%i%%j%%k

SET DBDUMP=%PRJDB%-%d%-%t%.dump

%PGPATH%pg_dump.exe -C -U %DBUSR% %PRJDB% > %SVPATH%%DBDUMP%
copy %SVPATH%%DBDUMP% %ALTPTH%

REM Backup BAT file script ends here

-------------------------------------------------------------------------
FAQ