RMAN Client

The RMAN client sends RMAN and SQL commands to the database.

The main commands implemented by RMAN include:

RMAN is similar in many respects to the SQL*Plus client. However, it was clearly developed separately and there are many minor differences between the two clients.

RMAN Catalog

RMAN maintains a catalog of backups created for the database. The catalog is always stored in the control file of the target database. The catalog may also optionally be stored in a CATALOG which is a dedicated schema, usually in a separate schema

When connecting to RMAN a target database must always specified. For example to connect to the local database using the bequeath protocol use:

  rman TARGET / 

If a catalog is not specified then RMAN will use data in the control files

Optionally NOCATALOG can be specified. For example:

  rman TARGET / NOCATALOG

If a catalog database exists this should be specified using the CATALOG clause. For example:

  rman TARGET / CATALOG catowner/catpassword@rman

RMAN Logging

There are several ways to log RMAN output.

LOG clause

A log file can be specified by the LOG clause in the RMAN command. For example:

  rman TARGET / LOG rman.log

The above command will redirect all output to the file rman.log

The log file is opened with write access so any previous output will be overwritten

Tee Command

The LOG command redirects output to the log file. Output is not displayed in the RMAN session.

For Linux/Unix output can alternatively be redirected to the tee command For example:

  rman TARGET / | tee rman.log

In the above example output will be displayed in the RMAN session, but will also be written to rman.log. Therefore the tee command is often preferable to the LOG clause.

SPOOL Command

In addition to command line LOG clause, logging can be enabled and disabled interactively using the SPOOL command. The syntax of this command differs from SQL*Plus.

To start spooling output to a file use:

RMAN> SPOOL LOG TO <filename>;

To stop spooling output use:

RMAN> SPOOL LOG OFF;

Timestamps

RMAN outputs timestamps within various commands including:

By default the timestamps will be in the format DD-MOM-YY. To specify an alternative timestamp format, set the NLS_DATE_FORMAT environment variable.

For example:

$ export NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS';
$ rman target / 

In this example the above command changed:

  2015-08-12
to
  2015-08-12 11:26:51

To include a comment in an RMAN command file or run block prefix the line with a hash sign e.g.:

RMAN> # This is a comment

Most commands including BACKUP, RESTORE and RECOVER must be terminated with a semicolon. Some commands including STARTUP, SHUTDOWN and CONNECT do not require a semicolon.

To exit the client use:

RMAN> EXIT

Note that no semicolon is required for the EXIT statement

Command Files

It is possible to execute external scripts (command files) from RMAN

The command file must contain valid RMAN commands.

The command file can have any name, but by convention the extension is ".rman"

The command file can be parameterized using positional substition variables which are &1, &2 etc.

There are three ways to execute command files within RMAN

Command Line

Command files can be executed within the command line For example:

rman target / @BackupDatabase.rman

RMAN Prommpt

Command files can be executed at the RMAN prompt. For example:

RMAN> @BackupDatabase.rman

Within a RUN command

Command files can be executed within a RUN command. For example:

RUN {
  ALLOCATE CHANNEL ch11 TYPE DISK;
  @BackupDatabase.rman
  RELEASE CHANNEL ch11;