Saturday, May 7, 2011

RMAN : Create Script Command


Create Script command is one of the Rman command which is used to stored script in recovery catalog.A stored script may be local or global. A local script is created for the current target database only, whereas a global script is available for use with any database registered in the recovery catalog.
We can use a stored script as an alternative to a command file for managing frequently used sequences of RMAN commands. The script is stored in the recovery catalog rather than on the file system.

The commands allowable within the brackets of the CREATE SCRIPT command are the same commands supported within a RUN block. Any command that is legal within a RUN command is permitted in the stored script.
Here, in this scenario we will perform the following steps :
1.) Create   Script
2.) Replace Script
3.) Execute Script 


Create Script  :  Assume that we want to create a local stored script for backing up database "noida". we start RMAN, connect to "noida" as TARGET, and connect to a recovery catalog. we create a stored script called rman_backup . 


C:\>rman
Recovery Manager: Release 11.1.0.6.0 - Production on Sat May 7 15:15:02 2011
Copyright (c) 1982, 2007, Oracle.  All rights reserved.
RMAN> connect target sys/ramtech@noida
connected to target database: NOIDA (DBID=1503672566)
RMAN> connect catalog  rcat/rcat@catdb
connected to recovery catalog database

RMAN> Create script rman_backup
2> Comment "backup Whole Database and archived redo logs "
3> {
4> backup incremental level 0
5> format "D:\rman_bkp\%U"
6> Database plus archivelog;
7> }


Replace Scripts :  To update stored scripts, we use the REPLACE SCRIPT command. If we are replacing a local script, then we must be connected to the target database that we connected to when we created the script. If the script does not already exist, then RMAN creates it.

RMAN> replace script rman_backup 
{
  backup database plus archivelog  skip inaccessible ;
}
         We can update global scripts by specifying the GLOBAL keyword .

Execute Script :   We use the EXECUTE SCRIPT command to run a stored script. If GLOBAL is specified, then a global script with this name must already exist in the recovery catalog; otherwise, RMAN returns error RMAN-06004. If GLOBAL is not specified, then RMAN searches for a local stored script defined for the current target database. If no local script with this name is found, then RMAN searches for a global script by the same name and executes it if one is found.

To execute a stored script run EXECUTE SCRIPT. This command requires a RUN block, as shown in the following example:


RMAN> run  

  excute script rman_backup; 
}


Enjoy  : -)

1 comment:

Anonymous said...

I do believe all of the ideas you've offered on your post.
They're very convincing and will certainly work.
Nonetheless, the posts are too brief for novices.

Could you please lengthen them a bit from next time?

Thanks for the post.

my web site :: angieslist.com