Oracle RMAN substituting variables

oracleoracle-11g-r2rman

I'm playing around with the USING clause in RMAN, but cannot seem to get it to work. Here is my RMAN command:

rman target username/password @${RMAN_DIR}/backup.rman using "db1"

When I run that (with double quotes, single quotes, no quotes, using a parameter), I get the error below.

I'm on Oracle 11.2.0.4 on Linux.

Argument     Value          Description
-----------------------------------------------------------------------------
target       quoted-string  connect-string for target database
catalog      quoted-string  connect-string for recovery catalog
nocatalog    none           if specified, then no recovery catalog
cmdfile      quoted-string  name of input command file
log          quoted-string  name of output message log file
trace        quoted-string  name of output debugging message log file
append       none           if specified, log is opened in append mode
debug        optional-args  activate debugging
msgno        none           show RMAN-nnnn prefix for all messages
send         quoted-string  send a command to the media manager
pipe         string         building block for pipe names
timeout      integer        number of seconds to wait for pipe input
checksyntax  none           check the command file for syntax errors
-----------------------------------------------------------------------------
Both single and double quotes (' or ") are accepted for a quoted-string.
Quotes are not required unless the string contains embedded white-space.

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00552: syntax error in command line arguments
RMAN-01009: syntax error: found "db1": expecting one of: "double-quoted-string, identifier, integer, single-quoted-string"
RMAN-01007: at line 2 column 1 file: command line arguments

Best Answer

The Linux shell must be interpreting the double quotes before the command gets to rman. Either escape the double quotes:

rman target username/password @${RMAN_DIR}/backup.rman using \"db1\"

or enclose the command in single quotes to prevent the shell from messing with it:

rman target username/password @${RMAN_DIR}'/backup.rman using "db1"'

In the latter case you will have to leave the environment variable outside the quoted command as you do want the shell to expand it.