Skip to content
Home » Oracle » 3 Ways to Set RMAN Log Location

3 Ways to Set RMAN Log Location

RMAN Log Location

RMAN is a client side utility like sqlplus used to interoperate with DB, we usually compose a script file or a batch file to run via cron job or schedule. If any problems result from RMAN, you can check the log file in order to debug them.

So the question is, where is RMAN Log Location?

There is no RMAN default log location in PFILE to set, so you must add the log location by yourself, if you are not specify one, you will miss the error messages and other important alerts.

There're 3 ways to reserve RMAN log location for you to trace:

1. OS Level

Just piping output to a file and show it in the console as well by using tee.

$ rman target / @full_backup.sql | tee -a /oracle/backup/rman.log

If you want them to go background, you can redirect all output to the log file.

$ rman target / @full_backup.sql > /oracle/backup/rman.log

A cumulated type of log would be like this:

$ rman target / @full_backup.sql >> /oracle/backup/rman.log

Separating logs for daily routines is also a good idea.

2. Command Level

Using the RMAN keyword LOG to specify the Location of RMAN Output, but the output will not show on you console.

$ rman target / @full_backup.sql LOG '/oracle/backup/rman.log'

3. Statement Level

We use SPOOL to output RMAN log to the destination we indicated.

RMAN> SPOOL LOG TO '/oracle/backup/rman.log';
RMAN> BACKUP DATABASE PLUS ARCHIVELOG;
RMAN> SPOOL LOG OFF;

Log Files on Daily Basis

The above examples may not be very good practices, because they log everyday's backup process in the same file. You must empty the file periodically to prevent the log file from growing too large.

A better practice is to log RMAN execution results in separate files based on dates, then you can easily to trace the problem by dates. The following is a sample script that you can use:

#!/bin/bash
...
LOGFILE=/oracle/backup/logs/rman_`date +%Y%m%d`.log
EXEFILE=/oracle/backup/scripts/DailyBackupCmd
...
rman target / @$EXEFILE LOG $LOGFILE
...

The file name would be like : rman_20201120.log.

Next, let's see how we set different backup locations in RMAN.

For more backup strategies, you may check the post: Routine Backup Strategies (0/5) – An Overview

For fixing the displayed date format in RMAN output, you may check the post: How to Set NLS_DATE_FORMAT in RMAN

Leave a Reply

Your email address will not be published. Required fields are marked *