Connecting to RMAN

with default OS credentials

c:\> rman target /

with regular username password credentials

c:\> rman target username/password

without showing password

c:\> rman target username

with specifying other SID than default one

c:\> rman target username/password@orcl

Scripting RMAN

There are two ways to run RMAN scripts.

  1. OS Shell Scripts (written in any scripting language that supports work with OS. Specific for all of this scripts (.sh in Linux or .cmd/.bat in Windows) is that they all contain RMAN commands. We run those scripts with some of the OS task schedulers like Cron (Linux) or Task Scheduler(Windows).
  2. Stored Scripts – we can embed them inside of a Recovery Catalog. Scripts can be local (for 1 DB) or global (for more DBs). They can be run either like previous ones or through the OEM.

Creating stored script in RMAN

C:/>rman target / catalog rman@orcl
recovery catalog database Password: -- enter password

RMAN> create script recoveryscript {
4> }

Creating RMAN script from an external data file. Lets say that we have written some RMAN script in the d:\script.txt

RMAN> create script rmansettings from file 'd:\script.txt';

Finding all existing scripts in RMAN

RMAN> list all script names;

Showing some RMAN script

RMAN> print script scriptName;

Replacing the existing script

RMAN> replace script backup_db
2> {backup database plus archivelog delete input;}

and finally executing of some script

RMAN> run {
2> execute script scriptName;
3> }

If we want to run a RMAN stored script from an OS script we should invoke the following line:

rman target / catalog=username/Pa$$w0rd@orcl script=scriptName

When RMAN script has some commands like shutdown DB for example, we need to authenticate and call the script ith the user that has rights to do that action on the DB!!!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: