Oi pessoal,

Espero que estejam bem!

Recebi uma ligação de um dos nossos clientes, resumindo, eles gostariam de limpar algum espaço no diretório $ORACLE_HOME/.patch_storage.

Existem diversas formas de fazer isso. Vou falar um pouco sobre elas aqui e focar neste post em como arquivar os patches.

Mas por favor, NÃO DELETE manualmente o conteúdo do diretório $ORACLE_HOME/.patch_storage!

Primeiramente, vamos entender qual é o objetivo de ter este diretório $ORACLE_HOME/.patch_storage. As informações abaixo foram traduzidas e coletadas desta nota:

Can You Delete $ORACLE_HOME/.patch_storage Directory ? (Doc ID 403218.1)

—————————————————————————————————-

1) Quando você aplica um patch interim no Oracle Home, a ferramenta OPatch armazena as informações do patch no diretório $ORACLE_HOME/.patch_storage. Dentro deste diretório, são criados diretórios separados para cada patch aplicado no Oracle Home. Interim patches são correções de bugs disponibilizadas aos clientes em resposta a bugs específicos. Critical Patch Update (CPU) e Release Update (RUs)/PatchSet Update (PSUs) também são um tipo de patches. O RU/CPU/PSU mais recente fará rollback do RU/CPU/PSU aplicado anteriormente, pois o RU/CPU/PSU é cumulativo. Portanto, essas informações de rollback estão no diretório .patch_storage.

2) Você pode encontrar um conflito de bugs e pode querer remover o patch conflitante. Esse processo é conhecido como rollback de patch. Durante a instalação do patch, o OPatch salva cópias de todos os arquivos que foram substituídos pelo novo patch antes que as novas versões desses arquivos sejam instaladas e as armazena em $ORACLE_HOME/.patch_storage/patch_ID/. Esses arquivos salvos são chamados de arquivos de rollback e são necessários para tornar o rollback de patches possível.

3) Toda vez que você aplica um patch, você faz mudanças no seu oraInventory. Às vezes, essa mudança pode corromper o oraInventory. A partir do Oracle RDBMS 10.2.0.X.X, quando você aplica um patch, o OPatch cria um snapshot do seu inventário e o armazena no diretório $ORACLE_HOME/.patch_storage/<patch-id_timestamp>. O script $ORACLE_HOME/.patch_storage/<patch-id_timestamp>/restore.sh que vem com o OPatch remove quaisquer alterações que foram feitas no inventário após a aplicação do patch.

Além disso, o fato diretório .patch_storage ser oculto, também reforça o fato de que não deve ser deletado.

—————————————————————————————————-

Perfeito, agora vamos explorar algumas opções para limpar o diretório $ORACLE_HOME/.patch_storage.

Como destacado por Mike Dietrich em seu blog post Cleaning up older patch artifacts – improving opatch performance, a partir do OPatch 12.2.0.1.37 de abril de 2023, temos alguns recursos adicionais. Você pode fazer o cleanup dos backups dos patches inativos (aplicados no passado e não mais necessários para rollback). Isso é um ótimo recurso!

Então, apenas para fins de demonstração, não vou limpar os backups antigos usando este recurso. Vamos apenas explorá-lo aqui.

Primeiro, podemos listar quais são os patches inativos elegíveis para exclusão:

opatch listorderedinactivepatches
Oracle Interim Patch Installer version 12.2.0.1.40
Copyright (c) 2024, Oracle Corporation.  All rights reserved.


Oracle Home       : /oracle/app/193/grid
Central Inventory : /oracle/app/oraInventory
   from           : /oracle/app/193/grid/oraInst.loc
OPatch version    : 12.2.0.1.40
OUI version       : 12.2.0.7.0
Log file location : /oracle/app/193/grid/cfgtoollogs/opatch/opatch2024-06-25_19-23-39PM_1.log

Invoking utility "listorderedinactivepatches"
List Inactive patches option provided

The oracle home has the following inactive patch(es) and their respective overlay patches:

The number of RU chains is  5

***** There are 5 inactive RU patches in chain 1
-Inactive RU/BP 29517242:Database Release Update : 19.3.0.0.190416 (29517242), installed on: Thu Apr 18 07:35:39 UTC 2019, with no overlays
-Inactive RU/BP 32218454:Database Release Update : 19.10.0.0.210119 (32218454), installed on: Tue Sep 28 20:37:06 UTC 2021, with no overlays
-Inactive RU/BP 33515361:Database Release Update : 19.14.0.0.220118 (33515361), installed on: Fri Sep 09 12:23:12 UTC 2022, with no overlays
-Inactive RU/BP 34419443:Database Release Update : 19.17.0.0.221018 (34419443), installed on: Thu Apr 13 16:02:58 UTC 2023, with no overlays
-Inactive RU/BP 35042068:Database Release Update : 19.19.0.0.230418 (35042068), installed on: Wed Sep 27 14:22:56 UTC 2023, with no overlays
-Active RU/BP 35643107:Database Release Update : 19.21.0.0.231017 (35643107), installed on: Sun Feb 25 04:51:29 UTC 2024, with no overlays

***** There are 5 inactive RU patches in chain 2
-Inactive RU/BP 29401763:TOMCAT RELEASE UPDATE 19.0.0.0.0 (29401763), installed on: Thu Apr 18 07:35:16 UTC 2019, with no overlays
-Inactive RU/BP 32240590:TOMCAT RELEASE UPDATE 19.0.0.0.0 (32240590), installed on: Tue Sep 28 21:00:18 UTC 2021, with no overlays
-Inactive RU/BP 33239955:TOMCAT RELEASE UPDATE 19.0.0.0.0 (33239955), installed on: Fri Sep 09 12:20:37 UTC 2022, with no overlays
-Inactive RU/BP 34580338:TOMCAT RELEASE UPDATE 19.0.0.0.0 (34580338), installed on: Thu Apr 13 16:08:18 UTC 2023, with no overlays
-Inactive RU/BP 35107512:TOMCAT RELEASE UPDATE 19.0.0.0.0 (35107512), installed on: Wed Sep 27 14:27:10 UTC 2023, with no overlays
-Active RU/BP 35553096:TOMCAT RELEASE UPDATE 19.0.0.0.0 (35553096), installed on: Sun Feb 25 04:50:10 UTC 2024, with no overlays

***** There are 6 inactive RU patches in chain 3
-Inactive RU/BP 29517247:ACFS RELEASE UPDATE 19.3.0.0.0 (29517247), installed on: Thu Apr 18 07:36:02 UTC 2019, with no overlays
-Inactive RU/BP 32218663:ACFS RELEASE UPDATE 19.10.0.0.0 (32218663), installed on: Tue Sep 28 20:55:00 UTC 2021, with no overlays
-Inactive RU/BP 33534448:ACFS RELEASE UPDATE 19.14.0.0.0 (33534448), installed on: Fri Sep 09 12:27:34 UTC 2022, with no overlays
-Inactive RU/BP 34428761:ACFS RELEASE UPDATE 19.17.0.0.0 (34428761), installed on: Thu Apr 13 16:07:08 UTC 2023, with no overlays
-Inactive RU/BP 35050325:ACFS RELEASE UPDATE 19.19.0.0.0 (35050325), installed on: Wed Sep 27 14:25:56 UTC 2023, with no overlays
-Inactive RU/BP 35652062:ACFS RELEASE UPDATE 19.21.0.0.0 (35652062), installed on: Sun Feb 25 04:55:03 UTC 2024, with no overlays
-Active RU/BP 35988503:ACFS Interim patch for 35988503, installed on: Thu Apr 18 15:58:06 UTC 2024, with no overlays

***** There are 5 inactive RU patches in chain 4
-Inactive RU/BP 29585399:OCW RELEASE UPDATE 19.3.0.0.0 (29585399), installed on: Thu Apr 18 07:36:24 UTC 2019, with no overlays
-Inactive RU/BP 32222571:OCW Interim patch for 32222571, installed on: Tue Sep 28 20:57:58 UTC 2021, with no overlays
-Inactive RU/BP 33529556:OCW RELEASE UPDATE 19.14.0.0.0 (33529556), installed on: Fri Sep 09 12:26:58 UTC 2022, with no overlays
-Inactive RU/BP 34444834:OCW RELEASE UPDATE 19.17.0.0.0 (34444834), installed on: Thu Apr 13 16:07:50 UTC 2023, with no overlays
-Inactive RU/BP 35050331:OCW RELEASE UPDATE 19.19.0.0.0 (35050331), installed on: Wed Sep 27 14:26:42 UTC 2023, with no overlays
-Active RU/BP 35655527:OCW RELEASE UPDATE 19.21.0.0.0 (35655527), installed on: Sun Feb 25 04:55:43 UTC 2024, with no overlays

***** There are 1 inactive RU patches in chain 5
-Inactive RU/BP 29340594:DBWLM RELEASE UPDATE 19.0.0.0.0 (29340594), installed on: Tue Sep 28 20:33:49 UTC 2021, with no overlays
-Active RU/BP 33575402:DBWLM RELEASE UPDATE 19.0.0.0.0 (33575402), installed on: Fri Sep 09 12:28:18 UTC 2022, with no overlays

OPatch succeeded.

Ótimo, não é?! Com esse recurso poderemos salvar muito espaço!

Em seguida, vou executar o opatch com a opção para deletar patches inativos, mas não vou deletar neste momento, então, vou adicionar a flag -report na minha operação OPatch. Vamos lá:

opatch util deleteinactivepatches -report
Oracle Interim Patch Installer version 12.2.0.1.40
Copyright (c) 2024, Oracle Corporation.  All rights reserved.


Oracle Home       : /oracle/app/193/grid
Central Inventory : /oracle/app/oraInventory
   from           : /oracle/app/193/grid/oraInst.loc
OPatch version    : 12.2.0.1.40
OUI version       : 12.2.0.7.0
Log file location : /oracle/app/193/grid/cfgtoollogs/opatch/opatch2024-06-25_19-26-33PM_1.log

Invoking utility "deleteinactivepatches"
Inactive Patches Cleanup option provided
Delete Inactive Patches .......

***** There are 5 inactive RU patches in chain 1

***** 4 inactive patches will be deleted
-To be deleted inactive RU/BP 29517242:Database Release Update : 19.3.0.0.190416 (29517242), installed on: Thu Apr 18 07:35:39 UTC 2019, with no overlays
-To be deleted inactive RU/BP 32218454:Database Release Update : 19.10.0.0.210119 (32218454), installed on: Tue Sep 28 20:37:06 UTC 2021, with no overlays
-To be deleted inactive RU/BP 33515361:Database Release Update : 19.14.0.0.220118 (33515361), installed on: Fri Sep 09 12:23:12 UTC 2022, with no overlays
-To be deleted inactive RU/BP 34419443:Database Release Update : 19.17.0.0.221018 (34419443), installed on: Thu Apr 13 16:02:58 UTC 2023, with no overlays
-To be retained inactive RU/BP 35042068:Database Release Update : 19.19.0.0.230418 (35042068), installed on: Wed Sep 27 14:22:56 UTC 2023, with no overlays
-Active RU/BP 35643107:Database Release Update : 19.21.0.0.231017 (35643107), installed on: Sun Feb 25 04:51:29 UTC 2024, with no overlays

***** There are 5 inactive RU patches in chain 2

***** 4 inactive patches will be deleted
-To be deleted inactive RU/BP 29401763:TOMCAT RELEASE UPDATE 19.0.0.0.0 (29401763), installed on: Thu Apr 18 07:35:16 UTC 2019, with no overlays
-To be deleted inactive RU/BP 32240590:TOMCAT RELEASE UPDATE 19.0.0.0.0 (32240590), installed on: Tue Sep 28 21:00:18 UTC 2021, with no overlays
-To be deleted inactive RU/BP 33239955:TOMCAT RELEASE UPDATE 19.0.0.0.0 (33239955), installed on: Fri Sep 09 12:20:37 UTC 2022, with no overlays
-To be deleted inactive RU/BP 34580338:TOMCAT RELEASE UPDATE 19.0.0.0.0 (34580338), installed on: Thu Apr 13 16:08:18 UTC 2023, with no overlays
-To be retained inactive RU/BP 35107512:TOMCAT RELEASE UPDATE 19.0.0.0.0 (35107512), installed on: Wed Sep 27 14:27:10 UTC 2023, with no overlays
-Active RU/BP 35553096:TOMCAT RELEASE UPDATE 19.0.0.0.0 (35553096), installed on: Sun Feb 25 04:50:10 UTC 2024, with no overlays

***** There are 6 inactive RU patches in chain 3

***** 5 inactive patches will be deleted
-To be deleted inactive RU/BP 29517247:ACFS RELEASE UPDATE 19.3.0.0.0 (29517247), installed on: Thu Apr 18 07:36:02 UTC 2019, with no overlays
-To be deleted inactive RU/BP 32218663:ACFS RELEASE UPDATE 19.10.0.0.0 (32218663), installed on: Tue Sep 28 20:55:00 UTC 2021, with no overlays
-To be deleted inactive RU/BP 33534448:ACFS RELEASE UPDATE 19.14.0.0.0 (33534448), installed on: Fri Sep 09 12:27:34 UTC 2022, with no overlays
-To be deleted inactive RU/BP 34428761:ACFS RELEASE UPDATE 19.17.0.0.0 (34428761), installed on: Thu Apr 13 16:07:08 UTC 2023, with no overlays
-To be deleted inactive RU/BP 35050325:ACFS RELEASE UPDATE 19.19.0.0.0 (35050325), installed on: Wed Sep 27 14:25:56 UTC 2023, with no overlays
-To be retained inactive RU/BP 35652062:ACFS RELEASE UPDATE 19.21.0.0.0 (35652062), installed on: Sun Feb 25 04:55:03 UTC 2024, with no overlays
-Active RU/BP 35988503:ACFS Interim patch for 35988503, installed on: Thu Apr 18 15:58:06 UTC 2024, with no overlays

***** There are 5 inactive RU patches in chain 4

***** 4 inactive patches will be deleted
-To be deleted inactive RU/BP 29585399:OCW RELEASE UPDATE 19.3.0.0.0 (29585399), installed on: Thu Apr 18 07:36:24 UTC 2019, with no overlays
-To be deleted inactive RU/BP 32222571:OCW Interim patch for 32222571, installed on: Tue Sep 28 20:57:58 UTC 2021, with no overlays
-To be deleted inactive RU/BP 33529556:OCW RELEASE UPDATE 19.14.0.0.0 (33529556), installed on: Fri Sep 09 12:26:58 UTC 2022, with no overlays
-To be deleted inactive RU/BP 34444834:OCW RELEASE UPDATE 19.17.0.0.0 (34444834), installed on: Thu Apr 13 16:07:50 UTC 2023, with no overlays
-To be retained inactive RU/BP 35050331:OCW RELEASE UPDATE 19.19.0.0.0 (35050331), installed on: Wed Sep 27 14:26:42 UTC 2023, with no overlays
-Active RU/BP 35655527:OCW RELEASE UPDATE 19.21.0.0.0 (35655527), installed on: Sun Feb 25 04:55:43 UTC 2024, with no overlays

OPatch is in report mode. No actual deletion happened. Reporting is done.

OPatch succeeded.

Excelente! Como você pode ver, temos vários patches a serem deletados (inativos), basicamente um patch a ser mantido (o patch anterior aplicado) e o patch ativo (que obviamente não vamos fazer nada com ele).

Como também apontado no post do Mike, você pode alterar o comportamento do OPatch para reter não apenas o patch anterior, mas também o penúltimo.

Para isso, você precisa alterar o arquivo $ORACLE_HOME/OPatch/config/opatch.properties.

Não vou alterá-lo, pois não vou usar este recurso aqui. Mas deixe-me mostrar o conteúdo do arquivo para você:

cat $ORACLE_HOME/OPatch/config/opatch.properties 
OPATCH_HEAP_MEMORY=3072
PS_OBFUSCATION=true
RETAIN_INACTIVE_PATCHES=1

Então, se quisermos manter o patch anterior e também o penúltimo, precisamos fazer mudanças no parâmetro RETAIN_INACTIVE_PATCHES=n, onde n é o número de patches anteriores que você gostaria de reter/manter.

Perfeito!

Agora, vamos falar sobre outro recurso: se você quiser, pode arquivar seus antigos diretórios de backup de patches. Esse recurso foi adicionado na versão OPatch 12.2.0.1.23 e posteriores.

Mike (ele novamente :-)) também postou sobre isso: Can I cleanup the previous Patch Bundles with opatch?, e foi exatamente isso que fiz para este cliente.

OK, vamos verificar nosso diretório .patch_storage (vou verificar os patches de GI):

[grid@DBNODE01 ~]$ cd $ORACLE_HOME/.patch_storage

[grid@DBNODE01 .patch_storage]$ ls -ltr 
total 480
drwxr-xr-x  3 grid oinstall   4096 Apr 18  2019 29517242_Apr_17_2019_23_27_10
drwxr-xr-x  3 grid oinstall   4096 Apr 18  2019 29517247_Apr_1_2019_15_08_20
drwxr-xr-x  3 grid oinstall   4096 Apr 18  2019 29585399_Apr_9_2019_19_12_47
drwx------  4 grid oinstall   4096 Sep 28  2021 32218454_Jan_14_2021_16_24_38
drwx------  4 grid oinstall   4096 Sep 28  2021 32218663_Dec_22_2020_12_20_04
drwx------  4 grid oinstall   4096 Sep 28  2021 32222571_Jan_15_2021_01_49_46
drwx------  4 grid oinstall   4096 Sep 28  2021 32240590_Jan_7_2021_22_55_01
drwx------  4 grid oinstall   4096 Sep 28  2021 29340594_Jan_8_2021_01_44_40
drwx------  4 grid oinstall   4096 Sep  9  2022 33239955_Aug_25_2021_09_25_51
drwx------  4 grid oinstall   4096 Sep  9  2022 33515361_Jan_13_2022_06_14_07
drwx------  4 grid oinstall   4096 Sep  9  2022 33529556_Jan_9_2022_21_15_36
drwx------  4 grid oinstall   4096 Sep  9  2022 33534448_Nov_3_2021_01_41_03
drwx------  4 grid oinstall   4096 Sep  9  2022 33575402_Nov_16_2021_09_32_52
drwx------  4 grid oinstall   4096 Apr 13  2023 34419443_Oct_14_2022_05_25_14
drwx------  4 grid oinstall   4096 Apr 13  2023 34428761_Aug_29_2022_05_57_36
drwx------  4 grid oinstall   4096 Apr 13  2023 34444834_Oct_7_2022_06_08_33
drwx------  4 grid oinstall   4096 Apr 13  2023 34580338_Sep_8_2022_11_16_07
drwxr-xr-x  4 grid oinstall   4096 Aug 23  2023 NRollback
drwx------  4 grid oinstall   4096 Sep 27  2023 35042068_Apr_6_2023_15_25_04
drwx------  4 grid oinstall   4096 Sep 27  2023 35050325_Feb_5_2023_22_16_18
drwx------  4 grid oinstall   4096 Sep 27  2023 35050331_Apr_7_2023_06_10_27
drwx------  4 grid oinstall   4096 Sep 27  2023 35107512_Feb_21_2023_10_59_25
drwx------  4 grid oinstall   4096 Feb 25 04:23 35553096_Jun_30_2023_01_01_59
drwx------  4 grid oinstall   4096 Feb 25 04:23 35643107_Oct_3_2023_13_34_29
drwx------  4 grid oinstall   4096 Feb 25 04:23 35652062_Sep_25_2023_16_59_58
drwx------  4 grid oinstall   4096 Feb 25 04:23 35655527_Sep_21_2023_10_48_31
drwxr-xr-x  4 grid oinstall   4096 Mar 28 17:51 35949090_Dec_20_2023_08_34_16
drwx------  4 grid oinstall   4096 Apr 18 15:44 35988503_Dec_12_2023_18_25_33
-rw-------  1 grid oinstall 125165 Apr 18 15:43 interim_inventory.txt
-rw-------  1 grid oinstall     93 Apr 18 15:43 LatestOPatchSession.properties
drwxr-xr-x 28 grid oinstall   4096 Apr 18 15:43 NApply
-rw-------  1 grid oinstall 120469 Apr 18 15:43 record_inventory.txt
-rw-r--r--  1 grid oinstall 113135 Apr 18 15:44 newdirs.txt

Perfeito, não vou arquivar todos os patches neste momento. Vamos arquivar por enquanto apenas os destacados abaixo:

Apr 18  2019 29517242_Apr_17_2019_23_27_10
Apr 18  2019 29517247_Apr_1_2019_15_08_20
Apr 18  2019 29585399_Apr_9_2019_19_12_47
Sep 28  2021 32218454_Jan_14_2021_16_24_38
Sep 28  2021 32218663_Dec_22_2020_12_20_04
Sep 28  2021 32222571_Jan_15_2021_01_49_46
Sep 28  2021 32240590_Jan_7_2021_22_55_01
Sep 28  2021 29340594_Jan_8_2021_01_44_40
Sep  9  2022 33239955_Aug_25_2021_09_25_51
Sep  9  2022 33515361_Jan_13_2022_06_14_07
Sep  9  2022 33529556_Jan_9_2022_21_15_36
Sep  9  2022 33534448_Nov_3_2021_01_41_03
Sep  9  2022 33575402_Nov_16_2021_09_32_52
Apr 13  2023 34419443_Oct_14_2022_05_25_14
Apr 13  2023 34428761_Aug_29_2022_05_57_36
Apr 13  2023 34444834_Oct_7_2022_06_08_33
Apr 13  2023 34580338_Sep_8_2022_11_16_07
Sep 27  2023 35042068_Apr_6_2023_15_25_04
Sep 27  2023 35050325_Feb_5_2023_22_16_18
Sep 27  2023 35050331_Apr_7_2023_06_10_27
Sep 27  2023 35107512_Feb_21_2023_10_59_25

Basicamente, precisamos usar o número do patch e, se estivermos planejando arquivar mais de um patch, podemos passar todos os números de patches separados por vírgula.

O que este recurso de arquivamento faz é comprimir os diretórios em formato zip e movê-los para um destino definido pelo parâmetro archive_dir. Claro, você precisa garantir que terá espaço no destino definido por archive_dir, caso contrário, não faz sentido arquivar seus patches inativos.

OK, então, basicamente, o comando é:

opatch util archive -patches <patch_number>,[<second_patch_number>,<third_patch_number>,…] -archive_dir <destination_folder_to_archive_the_patches>

Então, vamos lá:

[grid@DBNODE01 .patch_storage]$ opatch util archive -patches 29517242,29517247,29585399,32218454,32218663,32222571,32240590,33239955,33515361,33529556,33534448,33575402,34419443,34428761,34444834,34580338,35042068,35050325,35050331,35107512 -archive_dir /sapcd/BKP_ORCL_PATCHES/dbnode01/
Oracle Interim Patch Installer version 12.2.0.1.40
Copyright (c) 2024, Oracle Corporation.  All rights reserved.


Oracle Home       : /oracle/app/193/grid
Central Inventory : /oracle/app/oraInventory
   from           : /oracle/app/193/grid/oraInst.loc
OPatch version    : 12.2.0.1.40
OUI version       : 12.2.0.7.0
Log file location : /oracle/app/193/grid/cfgtoollogs/opatch/opatch2024-06-25_15-25-54PM_1.log

Invoking utility "archive"

Archiving Patch - 33515361 ....
Sucessfully archived patch - 33515361 in /sapcd/BKP_ORCL_PATCHES/dbnode01/33515361_Jan_13_2022_06_14_07.zip

Archiving Patch - 35107512 ....
Sucessfully archived patch - 35107512 in /sapcd/BKP_ORCL_PATCHES/dbnode01/35107512_Feb_21_2023_10_59_25.zip

Archiving Patch - 32222571 ....
Sucessfully archived patch - 32222571 in /sapcd/BKP_ORCL_PATCHES/dbnode01/32222571_Jan_15_2021_01_49_46.zip

Archiving Patch - 32240590 ....
Sucessfully archived patch - 32240590 in /sapcd/BKP_ORCL_PATCHES/dbnode01/32240590_Jan_7_2021_22_55_01.zip

Archiving Patch - 35042068 ....
Sucessfully archived patch - 35042068 in /sapcd/BKP_ORCL_PATCHES/dbnode01/35042068_Apr_6_2023_15_25_04.zip

Archiving Patch - 29517242 ....
Sucessfully archived patch - 29517242 in /sapcd/BKP_ORCL_PATCHES/dbnode01/29517242_Apr_17_2019_23_27_10.zip

Archiving Patch - 33575402 ....
Sucessfully archived patch - 33575402 in /sapcd/BKP_ORCL_PATCHES/dbnode01/33575402_Nov_16_2021_09_32_52.zip

Archiving Patch - 32218454 ....
Sucessfully archived patch - 32218454 in /sapcd/BKP_ORCL_PATCHES/dbnode01/32218454_Jan_14_2021_16_24_38.zip

Archiving Patch - 32218663 ....
Sucessfully archived patch - 32218663 in /sapcd/BKP_ORCL_PATCHES/dbnode01/32218663_Dec_22_2020_12_20_04.zip

Archiving Patch - 34428761 ....
Sucessfully archived patch - 34428761 in /sapcd/BKP_ORCL_PATCHES/dbnode01/34428761_Aug_29_2022_05_57_36.zip

Archiving Patch - 34580338 ....
Sucessfully archived patch - 34580338 in /sapcd/BKP_ORCL_PATCHES/dbnode01/34580338_Sep_8_2022_11_16_07.zip

Archiving Patch - 34419443 ....
Sucessfully archived patch - 34419443 in /sapcd/BKP_ORCL_PATCHES/dbnode01/34419443_Oct_14_2022_05_25_14.zip

Archiving Patch - 33534448 ....
Sucessfully archived patch - 33534448 in /sapcd/BKP_ORCL_PATCHES/dbnode01/33534448_Nov_3_2021_01_41_03.zip

Archiving Patch - 29585399 ....
Sucessfully archived patch - 29585399 in /sapcd/BKP_ORCL_PATCHES/dbnode01/29585399_Apr_9_2019_19_12_47.zip

Archiving Patch - 33239955 ....
Sucessfully archived patch - 33239955 in /sapcd/BKP_ORCL_PATCHES/dbnode01/33239955_Aug_25_2021_09_25_51.zip

Archiving Patch - 34444834 ....
Sucessfully archived patch - 34444834 in /sapcd/BKP_ORCL_PATCHES/dbnode01/34444834_Oct_7_2022_06_08_33.zip

Archiving Patch - 35050331 ....
Sucessfully archived patch - 35050331 in /sapcd/BKP_ORCL_PATCHES/dbnode01/35050331_Apr_7_2023_06_10_27.zip

Archiving Patch - 29517247 ....
Sucessfully archived patch - 29517247 in /sapcd/BKP_ORCL_PATCHES/dbnode01/29517247_Apr_1_2019_15_08_20.zip

Archiving Patch - 35050325 ....
Sucessfully archived patch - 35050325 in /sapcd/BKP_ORCL_PATCHES/dbnode01/35050325_Feb_5_2023_22_16_18.zip

Archiving Patch - 33529556 ....
Sucessfully archived patch - 33529556 in /sapcd/BKP_ORCL_PATCHES/dbnode01/33529556_Jan_9_2022_21_15_36.zip
Succesfully verified the created archive. Deleting the original patch from  - /oracle/app/193/grid/.patch_storage/33515361_Jan_13_2022_06_14_07
Succesfully verified the created archive. Deleting the original patch from  - /oracle/app/193/grid/.patch_storage/35107512_Feb_21_2023_10_59_25
Succesfully verified the created archive. Deleting the original patch from  - /oracle/app/193/grid/.patch_storage/32222571_Jan_15_2021_01_49_46
Succesfully verified the created archive. Deleting the original patch from  - /oracle/app/193/grid/.patch_storage/32240590_Jan_7_2021_22_55_01
Succesfully verified the created archive. Deleting the original patch from  - /oracle/app/193/grid/.patch_storage/35042068_Apr_6_2023_15_25_04
Succesfully verified the created archive. Deleting the original patch from  - /oracle/app/193/grid/.patch_storage/29517242_Apr_17_2019_23_27_10
Succesfully verified the created archive. Deleting the original patch from  - /oracle/app/193/grid/.patch_storage/33575402_Nov_16_2021_09_32_52
Succesfully verified the created archive. Deleting the original patch from  - /oracle/app/193/grid/.patch_storage/32218454_Jan_14_2021_16_24_38
Succesfully verified the created archive. Deleting the original patch from  - /oracle/app/193/grid/.patch_storage/32218663_Dec_22_2020_12_20_04
Succesfully verified the created archive. Deleting the original patch from  - /oracle/app/193/grid/.patch_storage/34428761_Aug_29_2022_05_57_36
Succesfully verified the created archive. Deleting the original patch from  - /oracle/app/193/grid/.patch_storage/34580338_Sep_8_2022_11_16_07
Succesfully verified the created archive. Deleting the original patch from  - /oracle/app/193/grid/.patch_storage/34419443_Oct_14_2022_05_25_14
Succesfully verified the created archive. Deleting the original patch from  - /oracle/app/193/grid/.patch_storage/33534448_Nov_3_2021_01_41_03
Succesfully verified the created archive. Deleting the original patch from  - /oracle/app/193/grid/.patch_storage/29585399_Apr_9_2019_19_12_47
Succesfully verified the created archive. Deleting the original patch from  - /oracle/app/193/grid/.patch_storage/33239955_Aug_25_2021_09_25_51
Succesfully verified the created archive. Deleting the original patch from  - /oracle/app/193/grid/.patch_storage/34444834_Oct_7_2022_06_08_33
Succesfully verified the created archive. Deleting the original patch from  - /oracle/app/193/grid/.patch_storage/35050331_Apr_7_2023_06_10_27
Succesfully verified the created archive. Deleting the original patch from  - /oracle/app/193/grid/.patch_storage/29517247_Apr_1_2019_15_08_20
Succesfully verified the created archive. Deleting the original patch from  - /oracle/app/193/grid/.patch_storage/35050325_Feb_5_2023_22_16_18
Succesfully verified the created archive. Deleting the original patch from  - /oracle/app/193/grid/.patch_storage/33529556_Jan_9_2022_21_15_36
Patch archive operation completed successfully.

OPatch succeeded.

Vamos listar novamente o conteúdo do nosso diretório:

[grid@DBNODE01 .patch_storage]$ ls -ltra
total 424
drwx------  4 grid oinstall   4096 Sep 28  2021 29340594_Jan_8_2021_01_44_40
drwxr-xr-x  4 grid oinstall   4096 Aug 23  2023 NRollback
drwx------  4 grid oinstall   4096 Feb 25 04:23 35643107_Oct_3_2023_13_34_29
drwx------  4 grid oinstall   4096 Feb 25 04:23 35652062_Sep_25_2023_16_59_58
drwx------  4 grid oinstall   4096 Feb 25 04:23 35553096_Jun_30_2023_01_01_59
drwx------  4 grid oinstall   4096 Feb 25 04:23 35655527_Sep_21_2023_10_48_31
drwxr-xr-x  4 grid oinstall   4096 Mar 28 17:51 35949090_Dec_20_2023_08_34_16
drwxr-xr-x 28 grid oinstall   4096 Apr 18 15:43 NApply
-rw-------  1 grid oinstall 120469 Apr 18 15:43 record_inventory.txt
-rw-------  1 grid oinstall 125165 Apr 18 15:43 interim_inventory.txt
-rw-------  1 grid oinstall     93 Apr 18 15:43 LatestOPatchSession.properties
-rw-r--r--  1 grid oinstall 113135 Apr 18 15:44 newdirs.txt
drwx------  4 grid oinstall   4096 Apr 18 15:44 35988503_Dec_12_2023_18_25_33
drwxr-xr-x 93 root oinstall   4096 Jun 20 11:08 ..
drwxr-xr-x  2 grid oinstall   4096 Jun 25 15:50 .archive_xml_bck
-rw-r--r--  1 grid oinstall   8607 Jun 25 15:50 .patch_archive_mapping.xml
drwx------ 12 grid oinstall   4096 Jun 25 15:52 .

Ótimo! Agora você pode ver dois novos arquivos e/ou diretórios:

  • .archive_xml_bck: aqui temos a execução anterior da operação de archive
  • .patch_archive_mapping.xml: aqui temos o mapeamento de cada patch arquivado e algumas informações adicionais, como: checksum para cada patch arquivado, o destino archive_dir, o timestamp quando o arquivamento ocorreu e o patchdir_checksum.

Ótimo!

Se quisermos reverter um dos patches arquivados, basicamente podemos desarquivá-los.

Para desarquivar um patch arquivado, basicamente precisamos executar este comando:

opatch util unarchive -patches <patch_number>,[<second_patch_number>,<third_patch_number>,...]

Também podemos limpar os patches arquivados (o que é realmente ótimo).

cd /sapcd/BKP_ORCL_PATCHES/dbnode01
opatch util cleanuparchives

Abaixo, temos algumas notas úteis do Metalink/My Oracle Support:

How to archive/unarchive patch directory under $ORACLE_HOME/.patch_storage ? (Doc ID 2867312.1)

How To Avoid Disk Full Issues Because OPatch Backups Take Big Amount Of Disk Space. (Doc ID 550522.1)

Can You Delete $ORACLE_HOME/.patch_storage Directory ? (Doc ID 403218.1)

OPatch 12.2.0.1.37+ Introduces a New Feature to Delete Inactive Patches in the ORACLE_HOME/.patch_storage Directory (Doc ID 2942102.1)

Espero que seja útil!

Abraços!

Vinicius