Archivelog are the key to media recovery. You should back them up regularly. To back up archived logs, use the BACKUP ARCHIVELOG command. Note that if backup optimization is enabled, then RMAN skips backups of archived logs that have already been backed up to the specified device. The target database must be mounted or open.

The following example backs up the database and all archived redo logs:

#Connect to RMAN
C:\RMAN

#Connect RMAN to target database
CONNECT TARGET SYS/pass@TEST1;

#Connect RMAN to recovery catalog (optional)
CONNECT CATALOG rman/cat@devdb;

#Issue RMAN BACKUP ... PLUS ARCHIVELOG command.
BACKUP DATABASE PLUS ARCHIVELOG;

The following example backup all archivelogs to configured disk or SBT channel:

BACKUP ARCHIVELOG ALL;

You can also specify a range of archived redo logs by time, SCN, or log sequence number, as in the following example:

BACKUP ARCHIVELOG
FROM TIME 'SYSDATE-30'
UNTIL TIME 'SYSDATE-7';

In the preceding example, all archived redo logs older than one week, going back for three weeks were backed up.

Backup only ArchiveLogs That Need Backups

The BACKUP ... NOT BACKED UP integer TIMES command specifies that RMAN should back up only those archived log files that have not been backed up at least integer times to the specified device. To determine the number of backups for a file, RMAN only considers backups created on the same device type as the current backup. The BACKED UP clause is a convenient way to back up archived logs to a specified device type. For example, you can specify that RMAN should keep two copies of each archived redo log on tape and skip additional backups.

#Connect to RMAN
C:\RMAN

#Connect RMAN to target database
CONNECT TARGET SYS/pass@TEST1;

#Connect RMAN to recovery catalog (optional)
CONNECT CATALOG rman/cat@devdb;
#Issue RMAN BACKUP ARCHIVELOG ALL command.
BACKUP ARCHIVELOG ALL NOT BACKED UP 2 TIMES;

Deleting ArchiveLogs After Backup

You can backup archivelog to tape or another disk destination. Once the backup is completed, we have the option to leave the logs in place, to delete only the logs that RMAN used for the backup, or to delete all copies of the archived logs that were backed up to tape.

The BACKUP ARCHIVELOG ... DELETE INPUT command deletes archived log files after they are backed up. This command eliminates the separate step of manually deleting archived redo logs.

In the following example, we backup all the archivelog files in the flash recovery area and then remove them from disk:

#Connect to RMAN
C:\RMAN

#Connect RMAN to target database
CONNECT TARGET SYS/pass@TEST1;

#Connect RMAN to recovery catalog (optional)
CONNECT CATALOG rman/cat@devdb;

#Issue RMAN BACKUP .. DELETE INPUT command.
BACKUP DEVICE TYPE SBT
ARCHIVELOG ALL
DELETE INPUT;

If archived log files are being sent to multiple locations, then only one set of the archived redo log files are deleted. If we want all copies to be deleted, we use delete all input instead of delete input.

Backing up and deleting only older archived redo log files can be accomplished by specifying a date range in the backup archivelog command:

BACKUP DEVICE TYPE SBT
ARCHIVELOG FROM TIME 'SYSDATE-30'
UNTIL TIME 'SYSDATE-7'
DELETE ALL INPUT;

In the preceding example, all archived redo logs older than one week, going back for three weeks, are copied to tape and deleted from disk. In addition, you can specify a range using SCNs or log sequence numbers.

ArchiveLog Failover

The archived redo log failover feature enables RMAN to complete a backup even when some archiving destinations are missing logs or contain logs with corrupt blocks. If at least one log corresponding to a given log sequence and thread is available in the flash recovery area or any of the archiving destinations, then RMAN tries to back it up. If RMAN finds a corrupt block in a log file during backup, it searches other destinations for a copy of that log without corrupt blocks.

Online Redo Log Switching

Another important RMAN feature is automatic online redo log switching. To make an open database backup of archivelogs that includes the most recent online redo log, you can execute the BACKUP command with any of the following clauses:

  • PLUS ARCHIVELOG
  • ARCHIVELOG ALL
  • ARCHIVELOG FROM ...

Before beginning the backup, RMAN switches out of the current redo log group, and archives all online redo logs that have not yet been archived, up to and including the redo log group that was current when the command was issued. This feature ensures that the backup contains all redo generated before the start of the command.

One of the most effective ways of backing up archived redo logs is the BACKUP ...PLUS ARCHIVELOG clause, which causes RMAN to do the following:

  1. Runs the ALTER SYSTEM ARCHIVE LOG CURRENT statement.
  2. Runs BACKUP ARCHIVELOG ALL. If backup optimization is enabled, then RMAN skips logs that it has already backed up to the specified device.
  3. Backs up the rest of the files specified in BACKUP command.
  4. Runs the ALTER SYSTEM ARCHIVE LOG CURRENT statement.
  5. Backs up any remaining archived logs generated during the backup. If backup optimization is not enabled, then RMAN backs up the logs generated in step 1 plus all the logs generated during the backup.

The preceding steps guarantee that datafile backups taken during the command are recoverable to a consistent state. Also, unless the online redo log is archived at the end of the backup, DUPLICATE is not possible with the backup.

Go to top
JSN Boot template designed by JoomlaShine.com