Search Postgresql Archives

pg_dump using MS-DOS BAT file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <newly created> 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

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


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux