Ever wanted to use variables in your RMAN scripts? Until and including 10g R2 this was impossible. Starting with 11g R1 it is possible.
Lets me show you a short example how to do it:
First we create a simple (and imcomplete) script with the following content:
connect target / backup &1;
The variable “&1″ will be replaced with the first command line argument supplied on the command line. “&2″ is the second argument and so on.
Suppose we want to backup our database we start RMAN with:
-bash-3.2$ rman target / @test.scr USING \"database\"
The resulting output will be:
Recovery Manager: Release 18.104.22.168.0 - Production on Mon Aug 2 08:16:07 2010 Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved. connected to target database: ORA11R2P (DBID=2658288218) RMAN> backup database; 2> Starting backup at 02-AUG-10 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=148 device type=DISK channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set input datafile file number=00001 name=/u01/oradata/ORA11R2P/system01.dbf input datafile file number=00002 name=/u01/oradata/ORA11R2P/sysaux01.dbf input datafile file number=00003 name=/u01/oradata/ORA11R2P/undotbs01.dbf input datafile file number=00005 name=/u01/oradata/ORA11R2P/testneu.dbf input datafile file number=00004 name=/u01/oradata/ORA11R2P/users01.dbf channel ORA_DISK_1: starting piece 1 at 02-AUG-10
As you can see in the bold line RMAN replaced the variable with the first argument specified on the command line (“database”).
With this method you can create powerful and yet simple scripts for backing up your database.