RMAN
Purpose
Use the RMAN command to start RMAN from the operating system command line.
RMAN connections to a database are specified and authenticated in the
same way as SQL*Plus connections to a database. The only difference is
that RMAN connections to a target or auxiliary database require the SYSDBA privilege. The AS SYSDBA keywords are implied and cannot be explicitly specified. See Oracle Database Administrator's Guide to learn about database connection options when using SQL*Plus.
Caution:
Good security practice requires that passwords should not be entered in
plain text on the command line. You should enter passwords in RMAN only
when requested by an RMAN prompt. See Oracle Database Security Guide to learn about password protection.
Prerequisites
You must issue the RMAN command and any options at the operating system command line rather than at the RMAN prompt.
Usage Notes
The command name that you enter at the operating system prompt is operating system-dependent. For example, enter rman in lowercase on Linux and UNIX systems.
If you start RMAN without specifying either CATALOG or NOCATALOG on the operating system command line, then the RMAN session is effectively in NOCATALOG mode unless you execute a CONNECT CATALOG command (see Example 2-126).
If you maintain a recovery catalog, then the best practice is to
connect RMAN to the recovery catalog before performing RMAN operations.
Syntax
cmdLine::=
Description of the illustration cmdline.gif
Semantics
cmdLine
Examples
Example 2-126 Connecting RMAN to a Target Database in Default NOCATALOG Mode
In this example, you start the RMAN client without specifying
database connection options at the operating system prompt. At the RMAN
prompt, you run the CONNECT command to connect to a target database. Because CONNECT CATALOG was not run at the RMAN prompt, RMAN connects in default NOCATALOG mode when the first command requiring a repository connection is run, which in this case is the BACKUP DATABASE command.
% rman
RMAN> CONNECT TARGET /
RMAN> BACKUP DATABASE;
Example 2-127 Connecting RMAN to an Auxiliary Database Instance
This example connects to target database prod and recovery catalog database catdb with net service names, and connects to an auxiliary database instance with operating system authentication.
% rman TARGET SYS@prod
Recovery Manager: Release 11.1.0.6.0 - Production
Copyright (c) 1982, 2007, Oracle. All rights reserved.
target database Password: password
connected to target database: PROD (DBID=39525561)
RMAN> CONNECT CATALOG rman@catdb
recovery catalog database Password: password
connected to recovery catalog database
RMAN> CONNECT AUXILIARY /
Example 2-128 Specifying Substitution Variables
Suppose that you want to create a Linux shell script that backs up
the database. You want to use shell variables so that you can pass
arguments to the RMAN backup script at run time. Substitution variables
solve this problem. First, you create a command file named whole_db.cmd with the following contents:
cat > /tmp/whole_db.cmd <<EOF
# name: whole_db.cmd
CONNECT TARGET /
BACKUP TAG &1 COPIES &2 DATABASE FORMAT '/disk2/db_%U';
EXIT;
EOF
Next, you write the following Linux shell script, which sets csh shell variables tagname and copies . The shell script starts RMAN, connects to target database prod1 , and runs whole_db.cmd . The USING clause passes the values in the variables tagname and copies to the RMAN command file at execution time.
#!/bin/csh
# name: runbackup.sh
# usage: use the tag name and number of copies as arguments
set tagname = $argv[1]
set copies = $argv[2]
rman @'/tmp/whole_db.cmd' USING $tagname $copies LOG /tmp/runbackup.out
# note that the preceding line is equivalent to:
# rman @'/tmp/whole_db.cmd' $tagname $copies LOG /tmp/runbackup.out
Finally, you execute the shell script runbackup.sh from a Linux shell as follows to create two backups of the database with the tag Q106 :
% runbackup.sh Q106 2
Example 2-129 Checking the Syntax of a Command File
Suppose that you create command file backup_db.cmd as follows:
cat > /tmp/backup_db.cmd <<EOF
CONNECT TARGET /
BACKUP DATABASE;
EXIT;
EOF
The following example checks the syntax of the contents of command file backup_db.cmd (sample output included):
% rman CHECKSYNTAX @'/tmp/backup_db.cmd'
Recovery Manager: Release 11.1.0.6.0 - Production on Wed Jul 11 17:51:30 2007
Copyright (c) 1982, 2007, Oracle. All rights reserved.
RMAN> CONNECT TARGET *
2> BACKUP DATABASE;
3> EXIT;
The cmdfile has no syntax errors
Recovery Manager complete.
Example 2-130 Running a Stored Script and Appending Output to a Message Log
This example connects to a target database using operating system authentication and then runs stored script wdbb . RMAN writes output to message log /tmp/wdbb.log .
% rman TARGET / SCRIPT wdbb LOG /tmp/wdbb.log
Example 2-131 Invoking the RMAN Pipe Interface
This example invokes the RMAN pipe newpipe with a 90 second timeout option.
% rman PIPE newpipe TARGET / TIMEOUT 90
Источник: http://docs.oracle.com/cd/B28359_01/backup.111/b28273/rcmsynta040.htm |