"JohnnyD" <johndnewcomb@xxxxxx> wrote in message
>I need help with writing some vb script. I am a very novice scripter
> and have no idea where to begin. I have a batch file backup script
> that exports the db file from a live running Sybase database shortly
> before ShadowProtect (backup program) images the drive, since Sybase
> is not VSS compatible. Here is my script:
> CD Eaglesoft\Shared Files
> DBBACKUP -d -t -c "eng=eaglesoft;uid=dba;pwd=sql" "D:\Online_Backup"
> The trouble I am having is that sometimes "dbbackup" does not finish
> the export and hangs somewhere in the process. I need a script that
> 1. kill dbackup.exe running in windows 2003 server processes if the
> script does not complete in 5 minutes and restart the script again.
> 2. Put a "failed" entry in the windows event log when it fails and
> needs to be restarted.
> Right now, I run this script as a batch file but imagine we would need
> to make it a vb script to accommodate the extra functionality
> Thanks Very Much,
> John Newcomb
Save the code below in c:\Tools\ByBackup.bat:
01. @echo off
02. set app=calc.exe
03. set parms=-d -t -c "eng=eaglesoft;uid=dba;pwd=sql" "D:\Online_Backup"
04. set delay=10
06. if not "%1"=="" goto Wait
07. start /b "Timer" c:\Tools\MyBackup.bat xxx
08. cd /d "d:\Eaglesoft\Shared Files"
09. %app% %parms%
10. if exist c:\Tools\MyBackup.flag (c:\Tools\MyBackup.bat) else (goto :eof)
13. if exist c:\Tools\MyBackup.flag del c:\Tools\MyBackup.flag
14. ping localhost -n %delay% > nul
15. tasklist | find /i "%app%" || goto :eof
16. echo %date% %time% > c:\Tools\MyBackup.flag
17. taskkill /f /im %app%
18. eventcreate.exe /.. /..
Lines 1..3: Adjust them to suit your requirements. Use calc.exe for testing
purposes, dbbackup.exe for the real thing.
Line 7: Start a second instance of c:\Tools\MyBackup.bat. The parameter xxx
ensures that the code after the ":Wait" label is executed. This instance
will run concurrently with the main part of the batch file.
Lines 8..9: Launch the backup process.
Line 10: Relaunch c:\Tools\MyBackup.bat if the first run failed.
Line 13: Delete the semaphore file if it exists.
Line 14: Pause for %delay% seconds.
Line 15: Exit if dbbackup.exe is no longer resident.
Line 16: Generate the semaphore file. It will be polled by Line 10.
Line 17: Kill dbbackup.exe.
Line 18: Create an event in the Event Logger.
Note: If you save this code under a name other than c:\Tools\MyBackup.bat
then you must adjust Lines 7 and 10 accordingly.
You probably need to add a counter so that the job doesn't run in circles
forever . . .