Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DB2 backup script, windows

Status
Not open for further replies.

unmaxpine

Technical User
Jul 26, 2007
14
CH
Hello,

Does anyone having experience in backup script under Windows 2000 SP4. Maybe I whill have to post in the Windows forum, let me know if you think it is a dos or db2 problem.

I basicly would like to try to back all my databases using a single batch script and I have problem retrieving and interpreting the return code of the db2cmd command:

In this sample, I test the backup of 3 databaes. The two first doesn't exist but the DBPROD exist:
Code:
for %%f in (TOTO,TRUP,DBPROD) do (

  echo "--------------------------------------">>%backuplogfile% 
  echo "Backup start of %%f en date du %mydate%" >>%backuplogfile%
  db2cmd /c /w /i db2 "BACKUP DATABASE %%f ONLINE USE TSM OPEN 1 SESSIONS WITH 2 BUFFERS BUFFER 1024 PARALLELISM 1 WITHOUT PROMPTING" >>%backuplogfile% 
  set retcode=%ERRORLEVEL%
if %ERRORLEVEL% GEQ 1  (
   echo "ERROR: Backup Error backupDB2, RC=%retcode% " >>%backuplogfile%
   echo "--------------------------------------">>%backuplogfile%
   call c:\admin\blat\bckfailed.bat %%f %mydate%
   set globalerror=1
 else 
   echo "Backup of %%f en date du %mydate% OK !" >>%backuplogfile%
   echo "--------------------------------------">>%backuplogfile%)
)


The result it that all databases in the loop will execute the command after the else, even the last backup is OK (return code 0).


Thanks in advance
 

Try this:
Code:
...
  set retcode=%ERRORLEVEL%
if %retcode% GEQ 1  (
...
[3eyes]


----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top