'리스토어'에 해당되는 글 1건

  1. 2009.03.17 backup copy의 timestamp 조회하기
DB backup copy를 사용하여 restore를 수행할 경우,
해당 backup copy의 timestamp를 알아내야 한다.

db2 DB의 backup copy가 생성된 timestamp를 확인하는 command는 다음과 같다.

db2 list history backup since YYYYMMDD for ${dbname}

정상적인 경우에는 다음과 같이 timestamp를 확인할 수 있다.

$ db2 list history backup since 20090316 for sample |more
                    List History File for sample
Number of matching file entries = 12
 Op Obj Timestamp+Sequence Type Dev Earliest Log Current Log  Backup ID
 -- --- ------------------ ---- --- ------------ ------------ --------------
  B  D  20090316183010001   N    O  S0422805.LOG S0422879.LOG 
 ----------------------------------------------------------------------------
  Contains 276 tablespace(s):
  00001 SYSCATSPACE
  00002 USERSPACE1
              ...

그러나, 간혹 다음과 같이 조회 시 오류가 발생하는 경우가 있다.

$ db2 list history backup since YYYYMMDD for ${dbname}
                    List History File for sample
Number of matching file entries = 12
SQL2155W  Changes have been made to the recovery history file since the open
scan was issued.

이는 내부적으로 history file에 대해 open scan이 발행된 후
이를 종료하기 위한 db2HistoryCloseScan API의 호출이
비정상적이었을 경우 발생하는 오류이다.

이런 경우는
다음 SQL로 timestamp를 조회할 수도 있고,

select  timestamp(start_time) as "Start Time (min)",
          case(operationType)         when 'F'  then 'Offline Full'
                                                 when 'N' then 'Online Full'
                                                 when 'I' then 'Offline Incremental'
                                                 when 'O' then 'Online Incremental'
                                                 when 'D' then 'Offline Delta' 
                                                 when 'E' then 'Online Delta'        
          else '?'       end as Type, 
          SQLCODE
 from TABLE(ADMIN_LIST_HIST()) AS LIST_HISTORY
where  operation = 'B' ;

위의 TABLE(ADMIN_LIST_HIST()) snapshot function을 수행하는 과정에서
history file scan이 초기화 되므로
간단히 ADMIN_LIST_HIST() function을 호출한 후에
본디의 list history backup 명령을 사용해서 조회가 가능해진다.
Posted by in0de
,