Showing posts with label RMAN DYNAMIC COMMAND. Show all posts
Showing posts with label RMAN DYNAMIC COMMAND. Show all posts

Tuesday, May 13, 2014

RMAN 11gR2 with dynamic command files using Subsitution Variables



1. Create RMAN command file that use two substitution variables.

 cat rman_3.cmd
#Take rman backup of database including current controlfile
connect target /
run
{
backup database
tag "&1"
format="+&2"
;
}
list backup of database
tag="&1";

cat rman_script.sh
#!/bin/sh
arg1="$1"
arg2="$2"
rman cmdfile="rman_3.cmd" using $arg1 $arg2
exit 0;

2. Run the rman_script.sh by passing two arguments ,first is the tag name and second is the format value

 sh rman_script.sh full_backup DATA

Recovery Manager: Release 11.2.0.4.0 - Production on Tue May 13 05:42:18 2014

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

RMAN> #Take rman backup of database including current controlfile
2> connect target *
3> run
4> {
5> backup database
6> tag "full_backup"
7> format="+DATA"
8> ;
9> }
10> list backup of database
11> tag="full_backup";
12>
13>
connected to target database: CVRMAN (DBID=657566608)

Starting backup at 13-MAY-14
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=47 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=+DATA/cvrman/datafile/system.256.847354793
input datafile file number=00002 name=+DATA/cvrman/datafile/sysaux.257.847354793
input datafile file number=00005 name=+DATA/cvrman/datafile/example.dbf
input datafile file number=00003 name=+DATA/cvrman/datafile/undotbs1.258.847354795
input datafile file number=00004 name=+DATA/cvrman/datafile/users.259.847354795
channel ORA_DISK_1: starting piece 1 at 13-MAY-14
channel ORA_DISK_1: finished piece 1 at 13-MAY-14
piece handle=+DATA/cvrman/backupset/2014_05_13/nnndf0_full_backup_0.290.847431749 tag=FULL_BACKUP comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:15
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 13-MAY-14
channel ORA_DISK_1: finished piece 1 at 13-MAY-14
piece handle=+DATA/cvrman/backupset/2014_05_13/ncsnf0_full_backup_0.292.847431825 tag=FULL_BACKUP comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 13-MAY-14


List of Backup Sets
===================


BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
17      Full    1.06G      DISK        00:01:14     13-MAY-14
        BP Key: 17   Status: AVAILABLE  Compressed: NO  Tag: FULL_BACKUP
        Piece Name: +DATA/cvrman/backupset/2014_05_13/nnndf0_full_backup_0.290.847431749
  List of Datafiles in backup set 17
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  1       Full 1012322    13-MAY-14 +DATA/cvrman/datafile/system.256.847354793
  2       Full 1012322    13-MAY-14 +DATA/cvrman/datafile/sysaux.257.847354793
  3       Full 1012322    13-MAY-14 +DATA/cvrman/datafile/undotbs1.258.847354795
  4       Full 1012322    13-MAY-14 +DATA/cvrman/datafile/users.259.847354795
  5       Full 1012322    13-MAY-14 +DATA/cvrman/datafile/example.dbf

Recovery Manager complete.