Before I run RMAN backups, I usually set a few things so as to enhance what is shown in the output. You don’t need to set these variables every time you log in and run an RMAN command. However, when troubleshooting or debugging issues, it’s almost always a good idea to perform the following tasks:
- Set NLS_DATE_FORMAT OS variable
- Set ECHO
- Show RMAN variables
The bulleted items are discussed in the following sections.
Before running any RMAN job, I set the OS variable NLS_DATE_FORMAT to include a time (hours, minutes, seconds) component; for example,
$ export NLS_DATE_FORMAT='dd-mon-yyyy hh24:mi:ss'
Additionally, if I have a shell script that calls RMAN, I put the prior line directly in the shell script (see the shell script at the end of this article for an example):
This ensures that when RMAN displays a date, it always includes the hours, minutes, and seconds as part of the output. By default, RMAN only includes the date component (DD-MON-YY) in the output. For instance, without setting NLS_DATE_FORMAT, when starting a backup, here is what RMAN displays:
Starting backup at 04-SEP-14
When you set the NLS_DATE_FORMAT OS variable to include a time component, the output will look like this instead:
Starting backup at 04-sep-2014 16:43:04
When troubleshooting, it’s essential to have a time component so that you can determine how long a command took to run or how long a command was running before a failure occurred. Oracle Support will almost always ask you to set this variable to include the time component before capturing output and sending it to them.
The only downside to setting the NLS_DATE_FORMAT is that if you set it to a value unknown to RMAN, connectivity issues can occur. For example, here the NLS_DATE_FORMAT is set to an invalid value:
$ export NLS_DATE_FORMAT='dd-mon-yyyy hh24:mi:sd'
$ rman target /
When set to an invalid value, you get this error when logging in to RMAN:
RMAN-03999: Oracle error occurred while converting a date: ORA-01821:
To unset the NLS_DATE_FORMAT variable, set it to a blank value, like so:
$ export NLS_DATE_FORMAT=''
Another value that I always set in any RMAN scripts is the ECHO command, seen here:
RMAN> set echo on;
This instructs RMAN to display the command that it’s running in the output, so you can see what RMAN command is running. along with any relevant error or output messages associated with the command. This is especially important when you’re running RMAN commands within scripts, because you’re not directly typing in a command (and may not know what command was issued within the shell script). For example, without SET ECHO ON, here is what is displayed in the output for a command:
Starting backup at...
With SET ECHO ON, this output shows the actual command that was run:
backup datafile 4;
Starting backup at...
From the prior output, you can see which command is running, when it started, and so on.
Another good practice is to run the SHOW ALL command within any script, as follows:
RMAN> show all;
This displays all the RMAN configurable variables. When troubleshooting, you may not be aware of something that another DBA has configured. This gives you a snapshot of the settings as they were when the RMAN session executed.