Tuesday, February 21, 2023

Copy Archivelogs From Standby DR to Primary

You may think the title of this article is wrong; what is the scenario that requires copying archivelogs from Standby to Primary?

I ran into a situation on a primary RAC DB data guarded by a standby RAC DB, where dozens of archivelogs were needed for goldengate replication got deleted by Oracle because of space pressure on Flash Recovery Area FRA. For my good luck, those archivelogs were still available on the Standby DB and hence in this article I'll demonstrate how to restore them back on the primary DB.

Note: Both Primary and Standby DBs are two nodes RAC, this explains why I've to specify the thread in most of RMAN commands.

Backup the Archivelogs on the Standby:

I managed to figure out the archivelogs sequence numbers I need to copy from the Standby DB and hence I used the following RMAN command to back up the needed Archivelogs on the Standby DB:

RUN{
ALLOCATE CHANNEL ch1 DEVICE TYPE DISK ;
ALLOCATE CHANNEL ch2 DEVICE TYPE DISK ;
ALLOCATE CHANNEL ch3 DEVICE TYPE DISK ;
ALLOCATE CHANNEL ch4 DEVICE TYPE DISK ;
backup as compressed backupset
archivelog sequence between 112700 and 112902 thread 1
format '/backup/archives/%d_%s_%p_%c_%t.arc.bkp'
archivelog sequence between 102590 and 102669 thread 2 format '/backup/archives/%d_%s_%p_%c_%t.arc.bkp';
}

Note: Using "as compressed backupset" option will shrink the backup file size, and it doesn't require a license.

Then, Copy the backed up Archivelogs from the Standby to one of the Primary DB nodes:
# scp /backup/archives/* oracle@primary_n1:/backup/archives


Restore the Archivelogs on the Primary:

On the Primary DB node where the backupfiles are copied, use the following command to Catalog the backup files, so they will be aware of by the Restore command:

RMAN> catalog start with '/backup/archives/';

On the same Primary Node I used the following RMAN command to restore the archives logs to their default location which is +RECO ASM diskgroup in my case:

RUN{
ALLOCATE CHANNEL ch1 DEVICE TYPE DISK ;
ALLOCATE CHANNEL ch2 DEVICE TYPE DISK ;
ALLOCATE CHANNEL ch3 DEVICE TYPE DISK ;
ALLOCATE CHANNEL ch4 DEVICE TYPE DISK ;
restore
archivelog from logseq=112700 until logseq=112902 thread 1
archivelog from logseq=102590 until logseq=102669 thread 2;
}

In case you want to restore the archivelogs to a non-default location i.e. /backup/archives/restored you can use "set archivelog destination" command as follows:

RUN{
ALLOCATE CHANNEL ch1 DEVICE TYPE DISK ;
ALLOCATE CHANNEL ch2 DEVICE TYPE DISK ;
ALLOCATE CHANNEL ch3 DEVICE TYPE DISK ;
ALLOCATE CHANNEL ch4 DEVICE TYPE DISK ;
set archivelog destination to '/backup/archives/restored';
restore
archivelog from logseq=112700 until logseq=112902 thread 1
archivelog from logseq=102590 until logseq=102669 thread 2;
}

 

No comments:

Post a Comment