1 backup com duas ou mais cópias para locais diferentes

Dúvidas, dicas e atualizações sobre o Treinamento Oracle Backup & Recovery.
Post Reply
gcomenale

1 backup com duas ou mais cópias para locais diferentes

Post by gcomenale »

Pessoal, estou com a seguinte dúvida:

Preciso fazer com que um backup seja feito para dois locais diferentes: /u01 e /u02.
A intenção não é fazer o backup em paralelismo, mas caso um dia eu perca o /u01 eu tenha todos os backups intactos no /u02 e vice versa.

Porém, sempre que eu aloco dois canais, um para cada local, ele cria um pedaço no /u01 e outro no /u02.

run {
ALLOCATE CHANNEL disk1 DEVICE TYPE DISK FORMAT '/u01/%U';
ALLOCATE CHANNEL disk2 DEVICE TYPE DISK FORMAT '/u02/%U';
alter system switch logfile;
backup datafile 6;
alter system switch logfile;
release channel disk1;
release channel disk2;
}

Backup Set Copy #1 of backup set 537
Device Type Elapsed Time Completion Time Compressed Tag
----------- ------------ --------------- ---------- ---
DISK 00:00:00 29-JUL-15 NO TAG20150729T173841

List of Backup Pieces for backup set 537 Copy #1
BP Key Pc# Status Piece Name
------- --- ----------- ----------
541 1 AVAILABLE /u01/i7qd9cp1_1_1

Backup Set Copy #2 of backup set 537
Device Type Elapsed Time Completion Time Compressed Tag
----------- ------------ --------------- ---------- ---
DISK 00:00:00 29-JUL-15 NO TAG20150729T173841

List of Backup Pieces for backup set 537 Copy #2
BP Key Pc# Status Piece Name
------- --- ----------- ----------
542 1 AVAILABLE /u01/i7qd9cp1_1_2



[oracle01][oracle][SID=SIC]/home/oracle> rm -rf /u01/i7qd9cp1_1_2
[oracle01][oracle][SID=SIC]/home/oracle> rman

Recovery Manager: Release 12.1.0.1.0 - Production on Wed Jul 29 17:40:21 2015

Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved.

connected to target database: SIC (DBID=1874771115)

RMAN> restore datafile 6 from tag ='TAG20150729T173841';

Starting restore at 29-JUL-15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=60 device type=DISK

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00006 to /u01/app/oracle/oradata/SIC/users01.dbf
channel ORA_DISK_1: reading from backup piece /u01/i7qd9cp1_1_1
channel ORA_DISK_1: ORA-19870: error while restoring backup piece /u01/i7qd9cp1_1_2
ORA-19505: failed to identify file "/u01/i7qd9cp1_1_2"
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3

failover to previous backup

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 07/29/2015 17:40:37
RMAN-06026: some targets not found - aborting restore
RMAN-06023: no backup or copy of datafile 6 found to restore

Ele entende que eu tive a intenção de fazer o backup em dois pedaços, mas na verdade eu quero UM backup com duas cópias em locais distintos.
Um não deve ser dependente do outro no caso de um restore.

Tentei utilizar o CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 2 e setar os FORMATs para os diretórios, mas ele fez o mesmo processo, um ficou dependente do outro.

portilho
Site Admin
Posts: 497
Joined: Wed May 29, 2013 8:51 am

Re: 1 backup com duas ou mais cópias para locais diferentes

Post by portilho »

Oi !
Acho que o que você procura é isto (o COPIES 2):

RMAN> BACKUP DEVICE TYPE DISK COPIES 2 DATAFILE 1 FORMAT '/home/ricardo/backup1/%U', '/home/ricardo/backup2/%U';

Starting backup at 30-JUL-15
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/home/ricardo/oracle/base/oradata/ORCL/system01.dbf
channel ORA_DISK_1: starting piece 1 at 30-JUL-15
channel ORA_DISK_1: finished piece 1 at 30-JUL-15 with 2 copies and tag TAG20150730T161630
piece handle=/home/ricardo/backup1/0gqdbsau_1_1 comment=NONE
piece handle=/home/ricardo/backup2/0gqdbsau_1_2 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15
Finished backup at 30-JUL-15

Starting Control File and SPFILE Autobackup at 30-JUL-15
piece handle=/home/ricardo/oracle/base/fast_recovery_area/ORCL/autobackup/2015_07_30/o1_mf_s_886436205_bvny0zox_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 30-JUL-15

RMAN>


Veja que não há paralelismo. O datafile é lido somente uma vez, por um único canal, mas o backup é gravado duas vezes, nos dois locais que indiquei.

gcomenale

Re: 1 backup com duas ou mais cópias para locais diferentes

Post by gcomenale »

Não funcionou:


RMAN> backup device type disk copies 2 datafile 6 format '/u01/%U_.dbf', '/u02/%U_.dbf';

Starting backup at 30-JUL-15
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00006 name=/u01/app/oracle/oradata/SIC/users01.dbf
channel ORA_DISK_1: starting piece 1 at 30-JUL-15
channel ORA_DISK_1: finished piece 1 at 30-JUL-15 with 2 copies and tag TAG20150730T182201
piece handle=/u01/iiqdc3m9_1_1_.dbf comment=NONE
piece handle=/u02/iiqdc3m9_1_2_.dbf comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 30-JUL-15

Starting Control File and SPFILE Autobackup at 30-JUL-15
piece handle=/u02/SIC/autobackup/2015_07_30/o1_mf_s_886443722_bvo5cv9c_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 30-JUL-15


RMAN> list backup tag TAG20150730T182201;


List of Backup Sets
===================


BS Key Type LV Size
------- ---- -- ----------
546 Full 1.67M
List of Datafiles in backup set 546
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
6 Full 2192603 30-JUL-15 /u01/app/oracle/oradata/SIC/users01.dbf

Backup Set Copy #1 of backup set 546
Device Type Elapsed Time Completion Time Compressed Tag
----------- ------------ --------------- ---------- ---
DISK 00:00:00 30-JUL-15 NO TAG20150730T182201

List of Backup Pieces for backup set 546 Copy #1
BP Key Pc# Status Piece Name
------- --- ----------- ----------
552 1 AVAILABLE /u01/iiqdc3m9_1_1_.dbf

Backup Set Copy #2 of backup set 546
Device Type Elapsed Time Completion Time Compressed Tag
----------- ------------ --------------- ---------- ---
DISK 00:00:00 30-JUL-15 NO TAG20150730T182201

List of Backup Pieces for backup set 546 Copy #2
BP Key Pc# Status Piece Name
------- --- ----------- ----------
553 1 AVAILABLE /u02/iiqdc3m9_1_2_.dbf


[oracle01][oracle][SID=SIC]/u02> rm /u02/iiqdc3m9_1_2_.dbf
[oracle01][oracle][SID=SIC]/u02> rman

Recovery Manager: Release 12.1.0.1.0 - Production on Thu Jul 30 18:23:20 2015

Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved.

connected to target database: SIC (DBID=1874771115)

RMAN> restore datafile 6 from tag='TAG20150730T182201';

Starting restore at 30-JUL-15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=44 device type=DISK

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00006 to /u01/app/oracle/oradata/SIC/users01.dbf
channel ORA_DISK_1: reading from backup piece /u01/iiqdc3m9_1_1_.dbf
channel ORA_DISK_1: ORA-19870: error while restoring backup piece /u02/iiqdc3m9_1_2_.dbf
ORA-19505: failed to identify file "/u02/iiqdc3m9_1_2_.dbf"
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3

failover to previous backup

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 07/30/2015 18:23:37
RMAN-06026: some targets not found - aborting restore
RMAN-06023: no backup or copy of datafile 6 found to restore


Ele continua aparentando que um arquivo é dependente do outro, como se fosse duas partes e não duas cópias.
Ou sou eu quem está fazendo o restore errado?

portilho
Site Admin
Posts: 497
Joined: Wed May 29, 2013 8:51 am

Re: 1 backup com duas ou mais cópias para locais diferentes

Post by portilho »

Não precisa usar a TAG.

Code: Select all

RMAN> LIST BACKUP;

specification does not match any backup in the repository

RMAN> BACKUP DEVICE TYPE DISK COPIES 2 DATAFILE 6 FORMAT '/home/ricardo/backup1/%U', '/home/ricardo/backup2/%U';

Starting backup at 31-JUL-15
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00006 name=/home/ricardo/oracle/base/oradata/ORCL/users01.dbf
channel ORA_DISK_1: starting piece 1 at 31-JUL-15
channel ORA_DISK_1: finished piece 1 at 31-JUL-15 with 2 copies and tag TAG20150731T064245
piece handle=/home/ricardo/backup1/0iqddf35_1_1 comment=NONE
piece handle=/home/ricardo/backup2/0iqddf35_1_2 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 31-JUL-15

Starting Control File and SPFILE Autobackup at 31-JUL-15
piece handle=/home/ricardo/oracle/base/fast_recovery_area/ORCL/autobackup/2015_07_31/o1_mf_s_886488166_bvpjrrpg_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 31-JUL-15

RMAN> HOST "rm /home/ricardo/backup1/0iqddf35_1_1";

host command complete

RMAN> HOST "ls -lh /home/ricardo/backup1/";

total 0
host command complete

RMAN> HOST "ls -lh /home/ricardo/backup2/";

total 1,4M
-rw-rw----. 1 ricardo ricardo 1,4M Jul 31 06:42 0iqddf35_1_2
host command complete

RMAN> alter database datafile 6 offline;

Statement processed

RMAN> restore datafile 6;

Starting restore at 31-JUL-15
using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00006 to /home/ricardo/oracle/base/oradata/ORCL/users01.dbf
channel ORA_DISK_1: reading from backup piece /home/ricardo/backup1/0iqddf35_1_1
channel ORA_DISK_1: errors found reading piece handle=/home/ricardo/backup1/0iqddf35_1_1
channel ORA_DISK_1: failover to piece handle=/home/ricardo/backup2/0iqddf35_1_2 tag=TAG20150731T064245
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 31-JUL-15

RMAN>

gcomenale

Re: 1 backup com duas ou mais cópias para locais diferentes

Post by gcomenale »

Funcionou! Obrigado!

O engraçado é que se eu usar o TAG ele diz que o backup não existe. Fico imaginando como seria eu quisesse voltar um backup específico que tenha uma das cópias excluídas...

portilho
Site Admin
Posts: 497
Joined: Wed May 29, 2013 8:51 am

Re: 1 backup com duas ou mais cópias para locais diferentes

Post by portilho »

Aqui funcionou o FROM TAG. Pode ser o Patchset, você está com 12.1.0.1, e eu com 12.1.0.2 último PSU.

Code: Select all

RMAN> LIST BACKUP;

specification does not match any backup in the repository

RMAN> BACKUP DEVICE TYPE DISK COPIES 2 DATAFILE 6 FORMAT '/home/ricardo/backup1/%U', '/home/ricardo/backup2/%U';

Starting backup at 05-AUG-15
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00006 name=/home/ricardo/oracle/base/oradata/ORCL/users01.dbf
channel ORA_DISK_1: starting piece 1 at 05-AUG-15
channel ORA_DISK_1: finished piece 1 at 05-AUG-15 with 2 copies and tag TAG20150805T072805
piece handle=/home/ricardo/backup1/0kqdqnk5_1_1 comment=NONE
piece handle=/home/ricardo/backup2/0kqdqnk5_1_2 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 05-AUG-15

Starting Control File and SPFILE Autobackup at 05-AUG-15
piece handle=/home/ricardo/oracle/base/fast_recovery_area/ORCL/autobackup/2015_08_05/o1_mf_s_886922886_bw3s9rpg_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 05-AUG-15

RMAN> LIST BACKUP;


List of Backup Sets
===================


BS Key  Type LV Size
------- ---- -- ----------
20      Full    1.34M
  List of Datafiles in backup set 20
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  6       Full 2496741    31-JUL-15 /home/ricardo/oracle/base/oradata/ORCL/users01.dbf

  Backup Set Copy #1 of backup set 20
  Device Type Elapsed Time Completion Time Compressed Tag
  ----------- ------------ --------------- ---------- ---
  DISK        00:00:00     05-AUG-15       NO         TAG20150805T072805

    List of Backup Pieces for backup set 20 Copy #1
    BP Key  Pc# Status      Piece Name
    ------- --- ----------- ----------
    23      1   AVAILABLE   /home/ricardo/backup1/0kqdqnk5_1_1

  Backup Set Copy #2 of backup set 20
  Device Type Elapsed Time Completion Time Compressed Tag
  ----------- ------------ --------------- ---------- ---
  DISK        00:00:00     05-AUG-15       NO         TAG20150805T072805

    List of Backup Pieces for backup set 20 Copy #2
    BP Key  Pc# Status      Piece Name
    ------- --- ----------- ----------
    24      1   AVAILABLE   /home/ricardo/backup2/0kqdqnk5_1_2

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
21      Full    17.48M     DISK        00:00:02     05-AUG-15     
        BP Key: 25   Status: AVAILABLE  Compressed: NO  Tag: TAG20150805T072806
        Piece Name: /home/ricardo/oracle/base/fast_recovery_area/ORCL/autobackup/2015_08_05/o1_mf_s_886922886_bw3s9rpg_.bkp
  SPFILE Included: Modification time: 05-AUG-15
  SPFILE db_unique_name: ORCL
  Control File Included: Ckp SCN: 2821534      Ckp time: 05-AUG-15

RMAN> HOST "rm /home/ricardo/backup1/*";

host command complete

RMAN> HOST "ls -lh /home/ricardo/backup1/";

total 0
host command complete

RMAN> HOST "ls -lh /home/ricardo/backup2/";

total 1,4M
-rw-rw---- 1 ricardo ricardo 1,4M Ago  5 07:28 0kqdqnk5_1_2
host command complete

RMAN> HOST "rm /home/ricardo/oracle/base/oradata/ORCL/users01.dbf";

host command complete

RMAN> ALTER DATABASE DATAFILE 6 OFFLINE;

Statement processed

RMAN> RESTORE DATAFILE 6 FROM TAG TAG20150805T072805;

Starting restore at 05-AUG-15
using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00006 to /home/ricardo/oracle/base/oradata/ORCL/users01.dbf
channel ORA_DISK_1: reading from backup piece /home/ricardo/backup1/0kqdqnk5_1_1
channel ORA_DISK_1: errors found reading piece handle=/home/ricardo/backup1/0kqdqnk5_1_1
channel ORA_DISK_1: failover to piece handle=/home/ricardo/backup2/0kqdqnk5_1_2 tag=TAG20150805T072805
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 05-AUG-15

RMAN> RECOVER DATAFILE 6;

Starting recover at 05-AUG-15
using channel ORA_DISK_1

starting media recovery
media recovery complete, elapsed time: 00:00:00

Finished recover at 05-AUG-15

RMAN> ALTER DATABASE DATAFILE 6 ONLINE;

Statement processed

RMAN>

gcomenale

Re: 1 backup com duas ou mais cópias para locais diferentes

Post by gcomenale »

Verdade, vou aplicar o último e testar.

portilho
Site Admin
Posts: 497
Joined: Wed May 29, 2013 8:51 am

Re: 1 backup com duas ou mais cópias para locais diferentes

Post by portilho »

:-)

gcomenale

Re: 1 backup com duas ou mais cópias para locais diferentes

Post by gcomenale »

Portilho, você tem o link do patch do 12.1.0.1.0 para o 12.1.0.2.0? Eu só estou encontrando do 12.1.0.2.0 para o 12.1.0.2.4. Seria do Linux x86-64. Ele só me trás dois patches, esse e do JVM.

portilho
Site Admin
Posts: 497
Joined: Wed May 29, 2013 8:51 am

Re: 1 backup com duas ou mais cópias para locais diferentes

Post by portilho »

É o próprio 12.1.0.2.
Como é um Patchset, é uma instalação completa, não é um Patch. tem que instalar em outro ORACLE_HOME.
Se for apenas uma máquina de testes, acho mais fácil criar o banco novamente após o 12.1.0.2 estar instalado. Se não, tem que fazer o upgrade do banco.

Post Reply