Recuperação de dados a partir de imagens de backup incremental e delta com substituição de caminho
Os backups levados em disco podem ter sido deslocados do local original para onde foram levados para um novo local. Em tal caso, o seu registro no arquivo de histórico Db2® não é consistente mais com a sua localização efetiva.
Ao falar em backups incrementais / delta, esses tipos de backups contam com uma cadeia de backups até o backup completo em que eles são baseados. Ao descarregar dados de backups incrementais / delta, toda esta cadeia de backups deve ser considerada. O local onde obter o último backup é retirado da cláusula FROM da cláusula USING BACKUP associado. Assim, mesmo que sua localização tenha mudado, seu novo local tem que ser especificado na cláusula FROM e não há problema para localizá-lo. Mas, para os backups anteriores na cadeia, sua localização é tomada a partir do arquivo de histórico Db2 . Como resultado, se o arquivo de histórico Db2 não refletir a localização efetiva desses backups, eles não podem ser encontrados e a execução falhar.
Para manejar tal cenário, as cláusulas OVERRIDE e SEARCH permitem especificar um novo local onde os backups anteriores na cadeia devem ser pesquisados pelo utilitário, para que eles possam ser encontrados e a execução poderia ter sucesso.
Esses exemplos utilizam o seguinte ambiente:
- Os backups foram retirados do banco de dados SAMPLE.
- um backup completo, tirado em 20140505161228 no diretório "/home/i1010".
- um backup incremental, tirado em 20140505161416, com 3 sessões nos diretórios correspondentes:
- "/home/i1010/SAMPLE/s1"
- "/home/i1010/SAMPLE/s2"
- "/home/i1010/SAMPLE/s3"
- um backup delta, tirado em 20140505161526 no diretório “/home/i1010/SAMPLE/delta”.
- outro backup delta, tirado em 20140505161543 no diretório “/home/i1010/LAST”.
- todos os backups tomados no diretório SAMPLE serão deslocados para um novo diretório chamado NEW_SAMPLE.
Exemplo 1: Descarregando dados com a cláusula OVERRIDE
[i1010@lat179(:) ~]$ db2hpu -i i1010 -f sysin_backup
INZM031I Optim High Performance Unload for Db2 06.01.00.001(140505)
64 bits 05/06/2014 (Linux lat17 x86_64)
INZI473I Memory limitations: 'unlimited' for virtual memory and 'unlimited' for data segment
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
000001 GLOBAL CONNECT TO SAMPLE
000002 USING BACKUP CATALOG SAMPLE FROM "/home/i1010/LAST" TAKEN AT 20140505161543;
000003 OVERRIDE ("/home/i1010/SAMPLE" BY "/home/i1010/NEW_SAMPLE")
000004;
000005 UNLOAD TABLESPACE
000006 DB2 NO LOCK NO FLUSH BUFFERPOOLS NO
000007
000008 USING BACKUP DATABASE SAMPLE FROM "/home/i1010/LAST" TAKEN AT 20140505161543;
000009 OVERRIDE ("/home/i1010/SAMPLE" BY "/home/i1010/NEW_SAMPLE")
000010 SELECT * FROM EMPLOYEE;
000011
000012 OUTFILE("out")
000013
000014 FORMAT DEL
000015 ;
INZU462I HPU control step start: 09:03:55.771.
INZU463I HPU control step end : 09:03:56.582.
INZU464I HPU run step start : 09:03:56.582.
INZU557I The partition 0 backup image taken at 20140505161228 is involved in the unload (Type FULL OFFLINE DATABASE, Device DISK).
INZU557I The partition 0 backup image taken at 20140505161416 is involved in the unload (Type INCREMENTAL OFFLINE DATABASE, Device DISK).
INZU557I The partition 0 backup image taken at 20140505161526 is involved in the unload (Type DELTA OFFLINE DATABASE, Device DISK).
INZU557I The partition 0 backup image taken at 20140505161543 is involved in the unload (Type DELTA OFFLINE DATABASE, Device DISK).
INZU410I HPU utility has unloaded 42 rows on lat179 host for I1010.EMPLOYEE in out.
INZU465I HPU run step end : 09:03:56.719.
INZI441I HPU successfully ended: Real time -> 0m0.947948s
User time -> 0m0.024996s : Parent -> 0m0.024996s, Children -> 0m0.000000s
Syst time -> 0m0.946856s : Parent -> 0m0.946856s, Children -> 0m0.000000s
Exemplo 2: Descarregando dados com a cláusula SEARCH
[i1010@lat179(:) ~]$ db2hpu -i i1010 -f sysin_backup
INZM031I Optim High Performance Unload for Db2 06.01.00.001(140519)
64 bits 05/20/2014 (Linux lat179 x86_64)
INZI473I Memory limitations: 'unlimited' for virtual memory and 'unlimited' for data segment
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8-
000001 GLOBAL CONNECT TO SAMPLE
000002 USING BACKUP CATALOG SAMPLE FROM "/home/i1010/LAST" TAKEN AT 20140505161543;
000003 SEARCH ("/home/i1010")
000004 ;
000005 UNLOAD TABLESPACE
000006 DB2 NO LOCK NO FLUSH BUFFERPOOLS NO
000007
000008 USING BACKUP DATABASE SAMPLE FROM "/home/i1010/LAST" TAKEN AT 20140505161543;
000009
000010 SELECT * FROM EMPLOYEE;
000011
000012 OUTFILE("out")
000013
000014 FORMAT DEL
000015 ;
INZU462I HPU control step start: 09:53:00.922.
INZU463I HPU control step end : 09:53:03.076.
INZU464I HPU run step start : 09:53:03.076.
INZU557I The partition 0 backup image taken at 20140505161228 is involved in the unload (Type FULL OFFLINE DATABASE, Device DISK).
INZU557I The partition 0 backup image taken at 20140505161416 is involved in the unload (Type INCREMENTAL OFFLINE DATABASE, Device DISK).
INZU557I The partition 0 backup image taken at 20140505161526 is involved in the unload (Type DELTA OFFLINE DATABASE, Device DISK).
INZU557I The partition 0 backup image taken at 20140505161543 is involved in the unload (Type DELTA OFFLINE DATABASE, Device DISK).
INZU410I HPU utility has unloaded 42 rows on lat179 host for I1010.EMPLOYEE in out.
INZU465I HPU run step end : 09:53:03.293.
INZI441I HPU successfully ended: Real time -> 0m2.370052s
User time -> 0m0.093985s : Parent -> 0m0.093985s, Children -> 0m0.000000s
Syst time -> 0m1.256808s : Parent -> 0m1.256808s, Children -> 0m0.000000s
Exemplo 3: Listagem dos backups envolvidos
Este caso de uso é uma listagem dos backups que estariam envolvidos em um descarregamento a partir do último backup delta mencionado acima. Ele é especificado com o uso da cláusula OVERRIDE.
[i1010@lat179(:) ~]$ db2hpu -i i1010 -f sysin_backup --list-backups
INZM031I Optim High Performance Unload for Db2 06.01.00.001(140505)
64 bits 05/05/2014 (Linux lat179 x86_64)
INZI473I Memory limitations: 'unlimited' for virtual memory and 'unlimited' for data segment
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
000001 GLOBAL CONNECT TO SAMPLE
000002 USING BACKUP CATALOG SAMPLE FROM "/home/i1010/LAST" TAKEN AT 20140505161543;
000003 OVERRIDE ("/home/i1010/SAMPLE" BY "/home/i1010/NEW_SAMPLE")
000004 ;
000005
000006 UNLOAD TABLESPACE
000007 DB2 NO LOCK NO FLUSH BUFFERPOOLS NO
000008
000009 USING BACKUP DATABASE SAMPLE FROM "/home/i1010/LAST" TAKEN AT 20140505161543;
000010 OVERRIDE ("/home/i1010/SAMPLE" BY "/home/i1010/NEW_SAMPLE")
000011 SELECT * FROM EMPLOYEE;
000012
000013 OUTFILE("out")
000014
000015 FORMAT DEL
000016 ;
INZU462I HPU control step start: 17:00:41.230.
INZU656I The list of backups determined by the USING BACKUP CATALOG clause for the partition 0:
INZU557I The partition 0 backup image taken at 20140505161228 is involved in the unload (Type FULL OFFLINE DATABASE, Device DISK).
INZU657I The partition 0 backup image taken at 20140505161228 (session #1) has been taken in the directory '/home/i1010'.
INZU666I The partition 0 backup image taken at 20140505161228 (session #1) might be found in the replacement directory '/home/i1010'.
INZU557I The partition 0 backup image taken at 20140505161416 is involved in the unload (Type INCREMENTAL OFFLINE DATABASE, Device DISK).
INZU657I The partition 0 backup image taken at 20140505161416 (session #1) has been taken in the directory '/home/i1010/SAMPLE/s1'.
INZU657I The partition 0 backup image taken at 20140505161416 (session #2) has been taken in the directory '/home/i1010/SAMPLE/s2'.
INZU657I The partition 0 backup image taken at 20140505161416 (session #3) has been taken in the directory '/home/i1010/SAMPLE/s3'.
INZU666I The partition 0 backup image taken at 20140505161416 (session #1) might be found in the replacement directory '/home/i1010/NEW_SAMPLE/s1'.
INZU666I The partition 0 backup image taken at 20140505161416 (session #2) might be found in the replacement directory '/home/i1010/NEW_SAMPLE/s2'.
INZU666I The partition 0 backup image taken at 20140505161416 (session #3) might be found in the replacement directory '/home/i1010/NEW_SAMPLE/s3'.
INZU557I The partition 0 backup image taken at 20140505161526 is involved in the unload (Type DELTA OFFLINE DATABASE, Device DISK).
INZU657I The partition 0 backup image taken at 20140505161526 (session #1) has been taken in the directory '/home/i1010/SAMPLE/delta'.
INZU666I The partition 0 backup image taken at 20140505161526 (session #1) might be found in the replacement directory '/home/i1010/NEW_SAMPLE/delta'.
INZU557I The partition 0 backup image taken at 20140505161543 is involved in the unload (Type DELTA OFFLINE DATABASE, Device DISK).
INZU657I The partition 0 backup image taken at 20140505161543 (session #1) has been taken in the directory '/home/i1010/LAST'.
INZU656I The list of backups determined by the USING BACKUP DATABASE clause for the partition 0:
INZU557I The partition 0 backup image taken at 20140505161228 is involved in the unload (Type FULL OFFLINE DATABASE, Device DISK).
INZU657I The partition 0 backup image taken at 20140505161228 (session #1) has been taken in the directory '/home/i1010'.
INZU666I The partition 0 backup image taken at 20140505161228 (session #1) might be found in the replacement directory '/home/i1010'.
INZU557I The partition 0 backup image taken at 20140505161416 is involved in the unload (Type INCREMENTAL OFFLINE DATABASE, Device DISK).
INZU657I The partition 0 backup image taken at 20140505161416 (session #1) has been taken in the directory '/home/i1010/SAMPLE/s1'.
INZU657I The partition 0 backup image taken at 20140505161416 (session #2) has been taken in the directory '/home/i1010/SAMPLE/s2'.
INZU657I The partition 0 backup image taken at 20140505161416 (session #3) has been taken in the directory '/home/i1010/SAMPLE/s3'.
INZU666I The partition 0 backup image taken at 20140505161416 (session #1) might be found in the replacement directory '/home/i1010/NEW_SAMPLE/s1'.
INZU666I The partition 0 backup image taken at 20140505161416 (session #2) might be found in the replacement directory '/home/i1010/NEW_SAMPLE/s2'.
INZU666I The partition 0 backup image taken at 20140505161416 (session #3) might be found in the replacement directory '/home/i1010/NEW_SAMPLE/s3'.
INZU557I The partition 0 backup image taken at 20140505161526 is involved in the unload (Type DELTA OFFLINE DATABASE, Device DISK).
INZU657I The partition 0 backup image taken at 20140505161526 (session #1) has been taken in the directory '/home/i1010/SAMPLE/delta'.
INZU666I The partition 0 backup image taken at 20140505161526 (session #1) might be found in the replacement directory '/home/i1010/NEW_SAMPLE/delta'.
INZU557I The partition 0 backup image taken at 20140505161543 is involved in the unload (Type DELTA OFFLINE DATABASE, Device DISK).
INZU657I The partition 0 backup image taken at 20140505161543 (session #1) has been taken in the directory '/home/i1010/LAST'.
INZU463I HPU control step end : 17:00:41.237.
INZI441I HPU successfully ended: Real time -> 0m0.007327s
User time -> 0m0.019996s : Parent -> 0m0.019996s, Children -> 0m0.000000s
Syst time -> 0m0.015997s : Parent -> 0m0.015997s, Children -> 0m0.000000s