본문 바로가기

wif LiNoUz/DATASTAGE

DATSTAGE, DB2 backup

작업 스케줄러에 걸어놓은 백업문

매일 오전 01:00

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

backup.bat

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

D:\sw\IBM\SQLLIB\BIN\db2cmd.exe db2 backup db xmeta online to d:\DB2\Backup_file include logs

exit

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





============================================================================================

============================================================================================



작업 스케줄러에 걸어놓은 백업 del문

매일 오전 12:50

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

backup_del.bat

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

:년월일 분리

set YEAR=%date:~0,4%

set YEAR2=%date:~0,4%

set MM=%date:~5,2% 

set MM2=%date:~5,2% 

set DD=%date:~8,2% 

:월,일 숫자화

set /a MM=1%MM%-100

set /a MM2=1%MM2%-100

set /a DD=1%DD%-100


set /a DD=DD-3

set /a TEMPSTR=%DD%

set /a MM2=MM2-3


if %MM2% LEQ 0 set /a MM2=12%MM2%&&set /a YEAR2=YEAR2-1


if %DD% GTR 0 goto end


:월처리

set /a MM=MM-1

if %MM% LEQ 0 set MM=12&&set /a YEAR=YEAR-1


echo set sub=0030101001010 >sub.bat

echo set /a DD=31-%%sub:~%MM%,1%% >>sub.bat

call sub.bat


:윤년처리

:4년주기

  set /a u=YEAR %% 4

  if not %u%==0 goto end

  set /a u=YEAR %% 400

  set /a v=YEAR %% 100

  if %v%==0 if not %u%==0 goto end

:2월체크

  if %MM% EQU 2 set /a DD=DD+1


:end

echo %YEAR%33333

set MM=0%MM%

set MM=%MM:~-2%


set DD=0%DD%

set DD=%DD:~-2%


if %TEMPSTR% LSS 0 set /a DD=%DD%%TEMPSTR%


set DT=%YEAR%%MM%%DD%


dir D:\DB2\Backup_file\*%DT%*

echo 해당파일을 삭제합니다.

timeout 5

del D:\DB2\Backup_file\*%DT%*

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