Oracle® Database Backup and Recovery Advanced User's Guide 10g Release 2 (10.2) Part Number B14191-02 |
|
|
View PDF |
Use the RMAN command line client to enter commands that you can use to manage all aspects of backup and recovery operations.
Even when you use the backup and recovery features in Enterprise Manager that are built on top of RMAN, an RMAN client executes behind the scenes.
Note:
All RMAN commands for Oracle release 8.1 and higher also work in Oracle Database 10g Release 2.RMAN processes most commands in the two phases discussed in this section:
During the compilation phase, RMAN determines which objects the command will access (for example, resolving a tablespace name into its component datafiles). Then, RMAN constructs a sequence of remote procedure calls (RPCs) that instruct the server sessions on the target database to perform the desired operation.
During the execution phase, RMAN sends the RPC calls to the target database, monitors their progress, and collects the results. If more than one channel is allocated, then RMAN can execute certain commands in parallel so that all of the channels' target database sessions are concurrently executing an RPC call.
RMAN uses a command language interpreter (CLI) that can execute commands in interactive or batch mode.
To run RMAN commands interactively, start RMAN and then type commands into the command-line interface. For example, you can start RMAN from the UNIX command shell and then execute interactive commands as follows:
% rman TARGET SYS/oracle@trgt CATALOG rman/cat@catdb
After the RMAN prompt is displayed, you can enter commands such as the following:
RMAN> BACKUP DATABASE;
A command file is a text file which contains RMAN commands as you would enter them at the command line. You can run the a command file by specifying its name on the command line. The contents of the command file will be interpreted as if entered at the command line. If the LOG command line argument is specified, RMAN directs output to the named log file. Command files are one way to automate scheduled backups through an operating system job control facility.
In this example, a sample RMAN script is placed into a command file called commandfile.rcv
. You can run this file from the operating system command line and write the output into the log file outfile.txt
as follows:
% rman TARGET / CATALOG rman/cat@catdb CMDFILE commandfile.rcv LOG outfile.txt
See Also:
Oracle Database Backup and Recovery Reference for more information about RMAN command line optionsA stored script is a block of RMAN job commands that is stored in the recovery catalog. By storing scripts in the recovery catalog, the script is available to any RMAN client that connects to the catalog and the target database. Stored scripts can be associated with a single database in the catalog, or they can be global stored scripts, which can be executed against any target database in the catalog.
See Also:
"Working with RMAN Stored Scripts in the Recovery Catalog" for more on stored scripts. Also refer to the sample scripts in the?/rdbms/demo
directory.There are RMAN commands which are only valid in RUN blocks. These typically involve setting up the environment within which the statements in the RUN block will execute. Typical of this group are ALLOCATE CHANNEL
and SET
NEWNAME FOR DATAFILE.
Using these commands outside of a RUN block will generate an error.
See Also:
The syntax diagrams for the RUN command in Oracle Database Backup and Recovery Reference regarding which commands are valid in RUN blocksThere are a number of RMAN commands which cannot be used in RUN blocks. Typically these are used to control the RMAN environment (connecting to different databases, or configuring RMAN defaults), or to manage or query the recovery catalog (including creating and using stored scripts). Here are some examples:
CONNECT
CONFIGURE
CREATE
CATALOG,
DROP
CATALOG,
UPGRADE
CATALOG
CREATE SCRIPT,
DELETE SCRIPT,
REPLACE SCRIPT
LIST
REPORT
You can include these commands inside command files, as long as they are not wrapped inside a RUN block. You cannot use them inside a stored script from the recovery catalog, because the contents of a stored script are executed within a RUN block.
See Also:
The syntax diagrams for the RUN command in Oracle Database Backup and Recovery Reference regarding which commands are valid in RUN blocksWhen you run RMAN in command line mode, it sends the output to the terminal. If you specify the LOG
option, then RMAN writes the output to a specified log file instead.
Output for currently executing RMAN jobs is also stored in the V$RMAN_OUTPUT
view, which reads only from memory (that is, the information is not stored in the control file). The V$RMAN_STATUS
view contains metadata about jobs in progress as well as completed jobs. The metadata for completed jobs is stored in the control file.