Professional Documents
Culture Documents
Note:$ORACLE_HOME/rdbms/admin/prgrmanc.sql
colalgorithm_nameformata15
colalgorithm_descriptionformata25
Encryption Algorithms
SELECT*FROMgv$rman_encryption_algorithms;
The default encryption algorithm is 128-bit AES.
Data Dictionary
Objects
Format Directives
DBA_HIST_INSTANCE_RECOVE
GV_$RECOVERY_STATUS
RY
V_$FLASH_RECOVERY_AREA_
DBA_RECOVERABLE_SCRIPT
USAGE
DBA_RECOVERABLE_SCRIPT_B
V_$INSTANCE_RECOVERY
LOCKS
DBA_RECOVERABLE_SCRIPT_E
V_$RECOVER_FILE
RRORS
DBA_RECOVERABLE_SCRIPT_P
V_$RECOVERY_FILE_DEST
ARAMS
GV_$INSTANCE_RECOVERY
V_$RECOVERY_FILE_STATUS
GV_$RECOVER_FILE
V_$RECOVERY_LOG
GV_$RECOVERY_FILE_STATUS V_$RECOVERY_PROGRESS
GV_$RECOVERY_LOG
V_$RECOVERY_STATUS
GV_$RECOVERY_PROGRESS
Format
Description
%a
%A
Zero-filled activation ID
%c
%d
Database name
%D
%e
%f
%F
Combines the DBID, day, month, year, and sequence into a unique
and repeatable generated name
%h
%I
DBID
%M
%n
%N
Repository
Initialization
Parameters
%p
Piece number within the backup set. This value starts at 1 for each
backup set and is incremented by 1 for each backup piece created.
If a PROXY is specified, the %p variable must be included in the
FORMAT string either explicitly or implicitly within %U.
%r
Resetlogs ID
%s
Backup set number. This number is a counter in the control file that
is incremented for each backup set. The counter value starts at 1
and is unique for the lifetime of the control file. If you restore a
backup control file, then duplicate values can result. CREATE
CONTROLFILE initializes the counter at 1.
%S
%t
%T
%u
%U
%Y
%%
compatible=10.2.0
log_archive_format=RMAN_%s_%r_%d.arc
remote_login_passwordfile=SHARED
showparameterarchive_format
To create a
permanent NAS
Mount
asroot
$unmount/mnt
$mkdir/u01
$chownoracle:dba/u01
$chmod755/u01
$cd/etc
$vifstab
192.168.2.200:/vol/vol1/alpha1/u01nfs
rw,bg,intr,hard,rsize=32768,wsize=32768,noac,no
lock,tcp,vers=300
Create RMAN
Repository and
Catalog
/*asLinuxuseroraclemodifytheTNSNAMES.ORA
topointtothedatabasethatwillhostthe
repositorycatalog:Then...*/
$sqlplus/assysdba
usingOMF
SQL>CREATETABLESPACEcat_tbs;
SQL>CREATEUSERrepoomega
IDENTIFIEDBYoracle1
DEFAULTTABLESPACEcat_tbs
TEMPORARYTABLESPACEtemp
QUOTAUNLIMITEDONcat_tbs;
RMAN>GRANTcreatesessionTOrepoomega
RMAN>GRANTrecovery_catalog_ownerTO
repoomega;
RMAN>GRANTexecuteONdbms_statsTO
repoomega;fordemos
intheoperatingsystemshell
$rmantarget/catalogrepoomega/oracle1@repos
RMAN>createcatalogtablespacecat_tbs;
RMAN>registerdatabase;
RMAN>reportschema;
RMAN>configuredefaultdevicetypetodisk;
RMAN>configuredevicetypediskparallelism
2backuptypetocopy;
RMAN>configureretentionpolicytorecovery
windowof7days;
RMAN>configurebackupoptimizationon;
/*asLinuxuseroraclemodifytheTNSNAMES.ORA
topointtothedatabasethatwillhostthe
repositorycatalog:Then...*/
$sqlplus/assysdba
colnameformata30
colvalueformata30
SELECTname,value
FROMgv$parameter
WHEREnameLIKE'%arch%';
altertheSPFILEasrequired
shutdownimmediate;
startupmount;
alterdatabasearchivelog;
alterdatabaseopen;
archiveloglist;
altersystemswitchlogfile;
archiveloglist;
RMAN>BACKUPTAGQ107DATABASEKEEPFOREVER;
Commands
@
Execute a series of
script of RMAN
commands stored in
an operating system
file. Do not leave
whitespace between
the @ and filename.
@<path_and_file_name>
rmanTARGET/@backup_db.rcv
or
RMAN>RUN{@backup_db.rman}
@@
Execute script files
located in the same
directory as the file
from which it has
been called
@@<path_and_file_name>
TBD
ADVISE FAILURE
Displays repair
options for the
specified failures.
Prints a summary of
the failures identified
by the Data Recovery
Advisor and implicitly
closes all open
failures that are
already fixed.
ADVISEFAILURE<ALL|CRITICAL|HIGH|LOW|
failure_number_list>
EXCLUDEFAILURE<failure_number_list>
RMAN>LISTFAILURE;
RMAN>ADVISEFAILUREALL;
RMAN>REPAIRFAILURE;
ALLOCATE CHANNEL
To manually allocate a channel, which is a connection between RMAN and a database instance.
Each connection initiates an database server session on the target or auxiliary instance: this server
session performs the work of backing up, restoring, or recovering RMAN backups.
Manually allocated channels (allocated by using ALLOCATE) should be distinguished from
automatically allocated channels (specified by using CONFIGURE). Manually allocated channels
apply only to the RUN job in which you issue the command. Automatic channels apply to any RMAN
job in which you do not manually allocate channels. You can always override automatic channel
configurations by manually allocating channels within a RUN command.
Each channel operates on one backup set or image copy at a time. RMAN automatically releases the
channel at the end of the job.
You can control the degree of parallelism within a job by allocating the desired number of channels.
Allocating multiple channels simultaneously allows a single job to read or write multiple backup sets
or disk copies in parallel. If you establish multiple connections, then each connection operates on a
separate backup set or disk copy.
Whether ALLOCATE CHANNEL causes operating system resources to be allocated immediately
depends on the operating system. On some platforms, operating system resources are allocated at
the time the command is issued. On other platforms, operating system resources are not allocated
until you open a file for reading or writing.
Allocating a Single Backup Channel
Allocate a disk
channel
ALLOCATE[AUXILIARY]CHANNEL<channel_name>[,
<channel_id>,DEVICETYPE
<device_type_name>[allocation_operand_list]
SQL>descgv$backup_device
SQL>SELECT*FROMgv$backup_device;
RMAN>RUN{
ALLOCATECHANNELd1DEVICETYPEDISK
FORMAT'/u01/backups/%U';
BACKUPDATABASEPLUSARCHIVELOG;
RELEASECHANNEL;
}
Allocates a tape
channel for a whole
database and
archived redo log
backup
RMANRUN{
ALLOCATECHANNELtape1DEVICETYPEsbt;
BACKUPDATABASEPLUSARCHIVELOG;
RELEASECHANNEL;
}
RUN{
ALLOCATECHANNELd1DEVICETYPEDISK
FORMAT'/u01/backups/%U';
ALLOCATECHANNELd2DEVICETYPEDISK
FORMAT'/u02/backups/%U';
BACKUPDATABASEPLUSARCHIVELOG;
different disks
When creating
multiple copies of a
backup, you can
specify the SET
BACKUP
COPIES command.
The following
example generates a
single backup of the
database to disk,
and then creates two
identical backups of
datafile 1 to two
different file systems
RELEASECHANNEL;
}
RUN{
ALLOCATECHANNELc1DEVICETYPE
DISKMAXPIECESIZE5M;
#ASCOPYisthedefault,soRMANcreates
imagecopies
BACKUPDATABASEPLUSARCHIVELOG;
SETBACKUPCOPIES=2;
BACKUPDATAFILE1FORMAT'/u01/backups/%U',
'/u02/backups/%U';
}
ALLOCATECHANNELFORMAINTENANCEDEVICETYPE
<device_specifier>[allocation_operand_list];
RMAN>ALLOCATECHANNELFORMAINTENANCEDEVICE
TYPEDISK;|
ALTER CLONE
?
ALTERCLONE....
TBD
ALTER DATABASE
ALTERDATABASE<MOUNT|OPEN|OPENRESETLOGS>;
Mount and open the
database
RMAN>STARTUPNOMOUNT;
RMAN>ALTERDATABASEMOUNT;
RMAN>BACKUPDATABASE;
RMAN>ALTERDATABASEOPEN;
RUN{
ALLOCATECHANNELch1DEVICETYPEsbt;
SETUNTILSCN1024;
RESTOREDATABASE;
RECOVERDATABASE;
ALTERDATABASEOPENRESETLOGS;
}
BACKUP
-- Back up a database, tablespace, datafile (current or copy), control file (current or copy), SPFILE,
archived log, or backup set.
BACKUP<BackupOperand>CHANNEL'<channel_id>'CHECKLOGICAL
COPIES<integer>
CUMULATIVEDEVICETYPE<deviceSpecifier>DISKRATIO<integer>
DURATION
<FileNameConversionSpecification>FILERPERSET<integer>FORCE
<AUXILIARYFORMAT<formatSpec,NEW>|FORMAT<formatSpec>
<forRecoveryOfSpec>
FULL
<keepoption>
MAXSETSIZE<sizeSpec>
<notBackedUpSpec>
NOCHECKSUMNOEXCLUDEPOOL<integer>PROXY[ONLY]REUSE
SECTIONSIZE<sizeSpec><skipSpec>
TAG'<tag_name>'VALIDATE
-- Back up a database, tablespace, datafile (current or copy), control file (current or copy), SPFILE,
archived log, or backup set.
BACKUP<BackupOperand>CHANNEL'<channel_id>'CHECKLOGICAL
COPIES<integer>
CUMULATIVEDEVICETYPE<deviceSpecifier>DISKRATIO<integer>
DURATION
<FileNameConversionSpecification>FILERPERSET<integer>FORCE
<AUXILIARYFORMAT<formatSpec,NEW>|FORMAT<formatSpec>
<forRecoveryOfSpec>
INCREMENTAL<LEVEL|FROMSCN><integer>
<keepoption>
MAXSETSIZE<sizeSpec>
<notBackedUpSpec>
NOCHECKSUMNOEXCLUDEPOOL<integer>PROXY[ONLY]REUSE
SECTIONSIZE<sizeSpec><skipSpec>
TAG'<tag_name>'VALIDATE
BACKUP ARCHIVELOG
Backs up copy of
each distinct log
sequence number
BACKUPARCHIVELOG<ALL|...>....
RMAN>BACKUPARCHIVELOGALL;
BACKUP AUXILIARY
?
BACKUPAUXILIARY....
TBD
BACKUP AS BACKUPSET
In the first RMAN
places datafiles 3
through 7 into one
backup set and
datafiles 8 and 9 into
another. In the
second all datafiles
go into a single
backup set.
BACKUPASBACKUPSETDEVICETYPE
<device_identifier>COPIES<integer>
DATABASEFORMAT'<location_and_format>'....
BACKUPASBACKUPSET(DATAFILE3,4,5,6,7)
(DATAFILE8,9);
BACKUPASBACKUPSETDATAFILE3,4,5,6,7,8,
9;
BACKUP AS COMPRESSED BACKUPSET
Create two copies of
a compressed
backupset.
BACKUPASCOMPRESSEDBACKUPSETDEVICETYPE
<device_identifier>
COPIES<integer>
DATABASEFORMAT'<location_and_format>'
BACKUPASCOMPRESSEDBACKUPSETDEVICETYPEDISK
COPIES2
DATABASEFORMAT'/u01/db_%U','/u02/db_%U';
BACKUP AS COPY
Backing up as an
image copy
BACKUPASCOPY<backup_specification>....
RUN{
ALLOCATECHANNELdev1DEVICETYPEDISKFORMAT
'/u01/%U';
ALLOCATECHANNELdev2DEVICETYPEDISKFORMAT
'/u02/%U';
BACKUPASCOPYTABLESPACEsystem,tools,
users,undotbs;
BACKUPASCOPYCURRENTCONTROLFILE;
}
BACKUP BLOCKS
?
BACKUPBLOCKS....
TBD
BACKUP CHANNEL
Manually allocate a
channel, in order to
specify that the
backup run by this
channel should go to
both pools first_copy
and second_copy.
Back up only logs
without 2 backups on
disk
BACKUPCHANNEL'<channel_id>'....
RUN{
ALLOCATECHANNELd2DEVICETYPEDISK
PARMS='ENV=(NSR_DATA_VOLUME_POOL=first_copy)';
ALLOCATECHANNELd1DEVICETYPEDISK
PARMS='ENV=(NSR_DATA_VOLUME_POOL=second_copy)';
BACKUPCHANNELd1ARCHIVELOGUNTILTIME
'SYSDATE'
NOTBACKEDUP2TIMESTAGSECOND_COPY;
BACKUPCHANNELd2ARCHIVELOGUNTILTIME
'SYSDATE'
NOTBACKEDUP2TIMESTAGFIRST_COPY;
}
BACKUP CHECK
SET MAXCORRUPT
indicates that no
more than 1
corruption should be
tolerated in each
datafile. Because the
CHECK LOGICAL
option is specified on
the BACKUP
command, RMAN
checks for both
physical and logical
corruption.
BACKUPCHECK[LOGICAL]
<database_specifications>
RUN{
SETMAXCORRUPTFORDATAFILE5,6,7,8TO1;
BACKUPCHECKLOGICALDATABASE;
}
BACKUP CONTROLFILECOPY
?
BACKUPCONTROLFILECOPY....
TBD
BACKUP COPY
?
BACKUPCOPY....
TBD
BACKUP COPIES
Define the number of
backup copies to
create
BACKUPCOPIES<integer>....
RUN{
BACKUPCOPIES2DEVICETYPEsbtBACKUPSET
ALL;
}
BACKUP CUMMULATIVE
?
BACKUPCUMMULATIVE....
TBD
BACKUP CURRENT
Backup the current
Control File to the
default or specified
location
BACKUPCURRENTCONTROLFILE[TODESTINATION
<destination_path>];
RUN{
BACKUPCURRENTCONTROLFILETO
DESTINATION'/u01/backups';
}
BACKUP DATABASE
Backup Database
Backup Database
Plus Archivelog
RUN{
ALLOCATECHANNELd1DEVICETYPEDISK;
BACKUPDATABASE;
}
RUN{
ALLOCATECHANNELd1DEVICETYPEDISK;
BACKUPDATABASEPLUSARCHIVELOG;
}
BACKUP DATAFILE
Datafile backup to
multiple locations
BACKUPDATAFILE<integer>[FORMAT
'<location_and_name_format>']
BACKUPDATAFILE<integer>[TO'<location>']
RUN{
ALLOCATECHANNELd1DEVICETYPEDISK;
BACKUPDATAFILE1FORMAT'/u01/backups/%U',
'/u02/backups/%U';
BACKUPDATAFILE6TO'/u01/backups',
'/u02/backups';
}
BACKUP DATAFILECOPY
?
BACKUPDATAFILECOPY....
TBD
BACKUP DB_FILE_NAME_CONVERT
?
BACKUPDB_FILE_NAME_CONVERT....
TBD
BACKUP DB_RECOVERY_FILE_DEST
?
BACKUPDB_RECOVERY_FILE_DEST....
TBD
BACKUPDEVICETYPE<DISK|SBT>....
RMAN>{
BACKUPDEVICETYPEsbt
DATAFILECOPYFROMTAG'LATESTCOPY'FORMAT
'Datafile%f_Database%d';
DELETECOPYTAG'LATESTCOPY';
}
BACKUP DISKRATIO
Populate each
backup set with
datafiles from the
specified number of
disks. To disable set
to 0.
BACKUP DURATION
RMAN>BACKUPDISKRATIO0;disable
RMAN>BACKUPDISKRATIO5;enable
BACKUPDURATION<HH:MI><backup_specification>
[MINIMIZE<LOAD|TIME>]
Backup will stop if it is
not completed in the BACKUPDURATION<HH:MI><backup_specification>
specified duration
PARTIAL
RMAN>BACKUPDURATION3:30DATABASE;
BACKUP FILE
?
BACKUPFILE....
TBD
BACKUP FILESPERSET
?
BACKUPFILESPERSET....
TBD
BACKUP...FORRECOVEROFCOPYWITHTAG....
RUN{
RECOVERCOPYOFDATABASEWITHTAG
'incr_update'UNTILTIME'SYSDATE7';
BACKUPINCREMENTALLEVEL1FORRECOVEROF
COPYWITHTAG'incr_upd'
DATABASE;
}
RMAN>BACKUPINCREMENTALLEVEL1FORRECOVER
OFCOPYWITHTAG'incr_upd'DATABASEFORMAT
'/oradata/rman/161932/inc_%d_%T_%t_%s_%p';
BACKUP FORCE
Forces RMAN to
ignore backup
optimization even if
CONFIGURE
BACKUP
OPTIMIZATION is ON
BACKUPFORCE<backup_specification>
RMAN>BACKUPFORCEDATABASE;
BACKUP FORMAT
Specify Backup
Format
BACKUPFORMAT<format_specification>....
RMAN>BACKUPFORMAT='UW_%d/%t/%s/%p'
ARCHIVELOGLIKE'%arc_dest%';
BACKUP FROM
?
BACKUPFROM....
TBD
BACKUP FULL
Creates a backup of
BACKUPFULL
RMAN>BACKUPFULL;
BACKUP INCREMENTAL
Incremental Backup
Level 0
BACKUPINCREMENTALLEVEL<level_number>
[CUMULATIVE|DIFFERENTIAL>....
BACKUPINCREMENTALLEVEL0DATABASE;
Incremental Backup
Level 1
Run to back up blocks
that have changed
since most recent
level 0 or 1
BACKUPINCREMENTALLEVEL1CUMULATIVEDATABASE;
BACKUPINCREMENTALLEVEL1DIFFERENTIAL
TABLESPACEusers;
BACKUPINCREMENTALLEVEL1CUMULATIVESKIP
INACCESSIBLEDATABASE;
BACKUPKEEP<FOREVER|UNTILTIME'date_string'
[RESTOREPOINT<restore_point_name>]
RMAN>SHUTDOWNIMMEDIATE;
RMAN>STARTUPMOUNT;
RMAN>BACKUPKEEPFOREVERFORMAT'?/dbs/
%U_longterm.cpy'
TAGLNGTRM_BCKDATAFILE5DATAFILE6;
RMAN>ALTERDATABASEOPEN;
BACKUP KEEP
?
BACKUPKEEP....
TBD
BACKUP MAXSETSIZE
?
BACKUPMAXSETSIZE....
TBD
BACKUP NOCHECKSUM
?
BACKUPNOCHECKSUM....
TBD
BACKUP NOEXCLUDE
?
BACKUPNOEXCLUDE....
TBD
BACKUP NOKEEP
?
BACKUPNOKEEP....
TBD
BACKUP NOT
?
BACKUPNOT....
TBD
BACKUP PROXY
?
BACKUPPROXY....
TBD
BACKUP POOL
?
BACKUPPOOL....
TBD
BACKUP RECOVERY
?
BACKUPRECOVERY....
TBD
BACKUP REUSE
?
BACKUPREUSE....
TBD
BACKUP SECTION
?
BACKUPSECTION....
TBD
BACKUP SETSIZE
?
BACKUPSETSIZE....
TBD
BACKUPSKIPREADONLY....
TBD
BACKUP SPFILE
Backup the Server
Parameter file to the
default or specified
location
BACKUPSPFILE[TODESTINATION
<destination_path>]
RMAN>BACKUPSPFILETODESTINATION
'/u01/backups';
BACKUP TAG
Backup the database
and apply a user
specified tag
BACKUPTAG'<tag_name>'....
RMAN>BACKUPTAG'weekly_full_db_bkup'DATABASE
MAXSETSIZE10M;
BACKUP TABLESPACE
?
BACKUPTABLESPACE....
TBD
BACKUP TO
?
BACKUPTO....
TBD
BACKUP VALIDATE
BACKUPVALIDATE....
TBD
BLOCKRECOVER
Block media recovery recovers an individual data block or set of data blocks within a datafile. This
type of recovery is useful if the data loss or corruption applies to a small number of blocks rather than
to an entire datafile.
Typically, block corruption is reported in error messages in trace files. Block-level data loss usually
results from:
BLOCKRECOVER ALLOW
?
BLOCKRECOVERALLOW....
TBD
BLOCKRECOVER ARCHIVELOG
?
BLOCKRECOVERARCHIVELOG....
TBD
BLOCKRECOVER AUXILIARY
?
BLOCKRECOVERAUXILIARY....
TBD
BLOCKRECOVER CHECK
?
BLOCKRECOVERCHECK....
TBD
BLOCKRECOVER CLEAR
?
BLOCKRECOVERCLEAR....
TBD
BLOCKRECOVER COPY
?
BLOCKRECOVERCOPY....
TBD
BLOCKRECOVER CORRUPTION
?
BLOCKRECOVERCORRUPTION....
TBD
BLOCKRECOVER DATABASE
BLOCKRECOVERDATABASE....
TBD
BLOCKRECOVER DATAFILE
Recover corrupt
blocks in 3 data files
BLOCKRECOVERDATAFILE<data_file_number>BLOCK
<block_list>
RMAN>BLOCKRECOVERDATAFILE2BLOCK12,13;
RMAN>BLOCKRECOVERDATAFILE2BLOCK
12,13DATAFILE3BLOCK5,98,99
DATAFILE4BLOCK19;
BLOCKRECOVERDATAFILE<data_file_number>BLOCK
<block_list>TABLESPACE<tablespace_name>FROMD
ATAFILECOPY
RUN{
BLOCKRECOVERDATAFILE3
BLOCK2,3,4,5TABLESPACEsalesDBA4194405,
4194409,4194412
FROMDATAFILECOPY;
}
BLOCKRECOVER DATAFILECOPY
?
BLOCKRECOVERDATAFILECOPY....
TBD
BLOCKRECOVER DELETE
?
BLOCKRECOVERDELETE....
TBD
BLOCKRECOVER DEVICE
?
BLOCKRECOVERDEVICE....
TBD
BLOCKRECOVER EXCLUDE
?
BLOCKRECOVEREXCLUDE....
TBD
BLOCKRECOVER FROM
?
BLOCKRECOVERFROM....
TBD
BLOCKRECOVERNOFILEUPDATE....
TBD
BLOCKRECOVER NOPARALLEL
BLOCKRECOVERNOPARALLEL....
TBD
BLOCKRECOVER NOREDO
?
BLOCKRECOVERNOREDO....
TBD
BLOCKRECOVER PARALLEL
?
BLOCKRECOVERPARALLEL....
TBD
BLOCKRECOVER PREVIEW
?
BLOCKRECOVERPREVIEW....
TBD
BLOCKRECOVER RESTORE
?
BLOCKRECOVERRESTORE....
TBD
BLOCKRECOVER SAVE
?
BLOCKRECOVERSAVE....
TBD
BLOCKRECOVERSKIPREADONLY....
TBD
BLOCKRECOVER SAVE
?
BLOCKRECOVERSAVE....
TBD
BLOCKRECOVER TABLESPACE
Limit block recovery
by backup tag
BLOCKRECOVERTABLESPACE<tablespace_name>...
BLOCKRECOVERTABLESPACESYSTEMDBA4194404,
4194405FROMTAG"weekly_backup";
BLOCKRECOVERTABLESPACE<tablespace_name>...
BLOCKRECOVERTABLESPACESYSTEMDBA4194404,
4194405RESTOREUNTILTIME'SYSDATE2';
BLOCKRECOVERCORRUPTIONLIST
BACKUPVALIDATEDATABASE;
BLOCKRECOVERCORRUPTIONLIST;
BLOCKRECOVER TEST
?
BLOCKRECOVERTEST....
TBD
BLOCKRECOVER UNDO
?
BLOCKRECOVERUNDO....
TBD
BLOCKRECOVER VALIDATE
?
BLOCKRECOVERVALIDATE....
TBD
CATALOG
Adds information about file copies and user-managed backups to the repository
CATALOG ARCHIVELOG
Back the named archive
log
CATALOGARCHIVELOG'<file_name_list>'
RMAN>CATALOGARCHIVELOG'
CATALOG BACKUP
Catalogs the backups
specified
CATALOGBACKUP...
RMAN>CATALOGBACKUP...
CATALOG BACKUPPIECE
Catalogs the backup
pieces in the new
location
CATALOGBACKUPPIECE<file_name_list>
RMAN>CATALOGBACKUPPIECE'/u01/c874220581
2008031501';USING
targetdatabasecontrolfileinsteadof
recoverycatalog
catalogedbackuppiecebackuppiece
handle=/u01/c8742205812008031501
RECID=8
STAMP=607695990;
CATALOG CLONE
?
CATALOGCLONE...
TBD
CATALOG CONTROLFILECOPY
CATALOGCONTROLFILECOPY
<controlfilecopy_name_list>
Catalog the control files
identified
RMAN>COPYCURRENTCONTROLFILETO'/stage';
RMAN>CATALOG
CONTROLFILECOPY'/stage/control01.ctl'
CATALOG DATAFILECOPY
Specifies that the
DATAFILECOPY<file_name_list>LEVEL<integer>
RMAN>CATALOG
DATAFILECOPY'/stage/users01.dbf';
RMAN>CATALOG
DATAFILECOPY'/u02/backup/users01.bak'LEVEL0;
RMAN>LISTCOPY;
CATALOG DB_RECOVERY_FILE_DEST
Catalog the Backup
Pieces held in the
location set by
DB_RECOVERY_FIL
E_DEST
CATALOGDB_RECOVERY_FILE_DEST
RMAN>CATALOGDB_RECOVERY_FILE_DEST;
CATALOG DEVICE
CATALOGDEVICE...
TBD
CATALOG RECOVERY
Catalog all files in the
currently enabled
flash recovery area
CATALOGRECOVERYAREA
RMAN>CATALOGRECOVERYAREA;
CATALOG START
Catalog all files in a
named disk location
CATALOGSTARTWITH<path_name>[NOPROMPT]
RMAN>CATALOGSTART
WITH'/u02/archivelog'NOPROMPT;
CHANGE
To make the following changes:
To change the status of backups, copies, and archived logs in the repository to AVAILABLE
or UNAVAILABLE. This feature is useful when a previously unavailable file is made available
again, or you do not want a specific backup or copy to be eligible to be restored but also do
not want to delete it.
To alter the repository status of usable backups and copies from prior incarnations.
To remove catalog records for backups and copies, and update the corresponding records in
the target control file to status DELETED. This feature is useful when you remove a file by
using an operating system command rather than the RMAN CHANGE command, and want
to remove its repository record as well.
To specify that a backup or copy should either abide by the currently configured retention
policy or be exempt from it.
CHANGE ARCHIVELOG
Move all archived
logs to a new
directory, uncatalog
CHANGEARCHIVELOG...
HOST'mv$ORACLE_HOME/oradata/trgt/arch/*
/fs2/arch';
CHANGEARCHIVELOGALLUNCATALOG;
CATALOGSTARTWITH'/fs2/arch';
CHANGEBACKUP...
CHANGEBACKUPOFSPFILECOMPLETEDBEFORE
'SYSDATE1'UNAVAILABLE;
CHANGEBACKUPOFARCHIVELOGALLNOKEEP;
CHANGE BACKUPSET
Change the status a
backup set
CHANGEBACKUPSET...
Change an ordinary
backup into a longterm backup
CHANGEBACKUPSET...
CHANGEBACKUPSET42UNAVAILABLE;
CHANGEBACKUPTAG'consistent_db_bkup'KEEP
FOREVERNOLOGS;
CHANGE CHANGEFAILURE
?
CHANGECHANGEFAILURE...
TBD
CHANGE CONTROLFILECOPY
?
CHANGECONTROLFILECOPY...
TBD
CHANGE COPY
?
CHANGECOPY...
TBD
CHANGE DATAFILECOPY
?
CHANGEDATAFILECOPY...
TBD
CHANGE DB_UNIQUE_NAME_FROM
?
CHANGEDB_UNIQUE_NAME_FROM...
TBD
CONFIGURE
To configure persistent settings affecting RMAN backup, restore, duplication, and maintenance jobs.
These configurations are in effect for any RMAN session until the configuration is cleared or
changed.
$rman
Configuration
Defaults
RMAN>SHOWALL
RMAN>CONFIGUREARCHIVELOGBACKUPCOPIESFORDEVICETYPE
DISKTO1;
RMAN>CONFIGUREARCHIVELOGDELETIONPOLICYTONONE;
RMAN>CONFIGUREBACKUPOPTIMIZATIONOFF;
RMAN>CONFIGURECONTROLFILEAUTOBACKUPOFF;
RMAN>CONFIGURECONTROLFILEAUTOBACKUPFORMATFORDEVICE
TYPEDISKTO'%F';
RMAN>CONFIGUREDATAFILEBACKUPCOPIESFORDEVICETYPE
DISKTO1;
RMAN>CONFIGUREDEFAULTDEVICETYPETODISK;
RMAN>CONFIGUREDEVICETYPEDISKPARALLELISM1BACKUP
TYPETOBACKUPSET;
RMAN>CONFIGUREENCRYPTIONFORDATABASEOFF;
RMAN>CONFIGUREENCRYPTIONALGORITHM'AES128';
RMAN>CONFIGUREMAXSETSIZETO2G;
RMAN>CONFIGURERETENTIONPOLICYTOREDUNDANCY1;
RMAN>CONFIGURESNAPSHOTCONTROLFILENAMETO
'/app/oracle/product/flash_recovery_area/snapshot.ctl';
CONFIGURE AUXILIARY
CONFIGUREAUXILIARYCHANNEL<DEVICE,
INTEGER>....
RMAN>CONFIGUREAUXILARY
CONFIGURE AUXNAME
Set and clear an
auxiliary name for a
datafile
CONFIGUREAUXNAMEFORDATAFILE
<data_file_number>TO<path_and_file_name>
CONFIGUREAUXNAMEFORDATAFILECLEAR
RMAN>CONFIGUREAUXNAMEFORDATAFILE5TO
'/home/oracle/auxfiles/aux1.f';
RMAN>CONFIGUREAUXNAMEFORDATAFILE4CLEAR;
CONFIGURE CHANNEL
CONFIGURECHANNEL<DEVICETYPE|INTEGER>
<configuration|CLEAR>
RMAN>CONFIGURECHANNELDEVICETYPE'SBT_TAPE'
CLEAR;
CONFIGURECLONENAME....
RMAN>CONFIGURECLONENAME
CONFIGURE COMPATIBLE
?
CONFIGURECOMPATIBLE....
RMAN>CONFIGURECOMPATIBLE
CONFIGURE COMPRESSION
Configure a backup
CONFIGURECOMPRESSIONALGORITHM<CLEAR|
'<quoted_string>'>
compression
algorithm
SELECTalgorithm_name,algorithm_description
FROMv$rman_compression_algorithm;
RMAN>CONFIGURECOMPRESSIONALGORITHM'ZLIB';
CONFIGURE CONTROLFILE
Enable autobackup
and configure the
default autobackup
format for a DISK
device
CONFIGURECONTROLFILEAUTOBACKUP
CONFIGURECONTROLFILEAUTOBACKUPON;
CONFIGURECONTROLFILEAUTOBACKUPFORMATFOR
DEVICETYPEDISKTO'/u02/%F';
CONFIGURE DB_UNIQUE_NAME
CONFIGUREDB_UNIQUE_NAME'<db_unique_name>'
<CLEAR|CONNECTIDENTIFIER'<quoted_string>'>
TBD
CONFIGUREENCRYPTIONALGORITHM<CLEAR|
encryption_algorithm>
SQL>colalgorithm_nameformata20
SQL>colalgorithm_descriptionformata25
SQL>SELECTalgorithm_name,
algorithm_description
FROMv$rman_encryption_algorithms;
RMAN>CONFIGUREENCRYPTIONALGORITHM'AES256';
RMAN>CONFIGUREENCRYPTIONCLEAR;
Configure Database
or Tablespace
Encryption
CONFIGUREENCRYPTIONFOR<DATABASE|TABLESPACE
<tablespace_name>>
<ON|OFF|CLEAR>
RMAN>CONFIGUREENCRYPTIONFORDATABASEON;
RMAN>CONFIGUREENCRYPTIONFOR
TABLESPACEuwdataOFF;
CONFIGUREEXCLUDE...
TBD
CONNECT
Creates a connection between RMAN and a target, auxiliary, or recovery catalog database
Auxiliary
CONNECTAUXILIARY
<user_id>/<password>@<instance>
$rmanauxiliaryoracle/oracle1@prodb
CONNECT
Catalog
$rmancatalogrepoomega/oracle1@repos
$rman
RMAN>connectcatalogrepoomega/oracle1@repos
Target only
CONNECTTARGET<user_id>/<password>@<instance>
$rmantarget/
$rman>
RMAN>connecttarget/catalogrepoomega/oracl
e1@repos
CONNECT
$rmantarget/catalogrepoomega/oracle1@repos
$rman>
RMAN>connecttarget/catalogrepoomega/oracl
e1@repos
Target without a
catalog
CONNECT
$rman
RMAN>connect
targetomega1/omega1@emrepNOCATALOG
CONVERT
Converts a datafile, tablespace or database to the format of a destination platform, in preparation for
transport across different platforms
CONVERT DATABASE
Uses CONVERT
DATABASE NEW
DATABASE to convert
datafiles and generate a
transport script
CONVERTDATABASENEWDATABASE'<db_name>'
TRANSPORTSCRIPT'<script_location>'
TOPLATFORM'<platform_name>'
DB_FILE_NAME_CONVERT'<source_location>
<destination_location>'
CONVERTDATABASE
NEWDATABASE'prodb'
TRANSPORT
SCRIPT'/tmp/convertdb/transportscript'
TOPLATFORM'LinuxIA(64bit)'
DB_FILE_NAME_CONVERT'/u01/oradata',
'/stage/dbfiles';
CONVERT DATAFILE
Converts the datafiles to
CONVERTDATAFILE<datafile_name_list>
DB_FILE_NAME_CONVERT'<source_location>
be transported to the
destination host format
and deposits the results
in /u02/oradata
<destination_location>'
FROMPLATFORM<original_platform_name>
CONVERTDATAFILE
'/tmp/transport_from_aix/u01/uwdata01.dbf',
'/tmp/transport_from_aix/u01/uwdata02.dbf',
'/tmp/transport_from_aix/u03/users01.dbf',
'/tmp/transport_from_aix/u03/users02.dbf'
DB_FILE_NAME_CONVERT
'/app/oracle/product/oradata','/stage/oradata',
'/tmp/transport_from_solaris/hr','/stage/oradat
a'
FROMPLATFORM'LinuxIA(64bit)';
CONVERT TABLESPACE
Convert a tablespaces to
64 bit Linux
CONVERTTABLESPACE<tablespace_name_list>TO
PLATFORM<platform_name>FORMAT
'<format_string>'
descv$transportable_platform
SELECTplatform_name,endian_format
FROMv$transportable_platform;
CONVERTTABLESPACEuwdata,usersTOPLATFORM
'LinuxIA(64bit)'
FORMAT
'/app/oracle/product/flash_recovery_area/linux6
4/%U';
COPY
?
COPYARCHIVELOG...(level,nochecksum,nokeep,
reuse,tag)
RMAN>COPYARCHIVELOG
?
?
COPYBACKUP...
RMAN>COPYBACKUP
COPYCHECK...
RMAN>COPYCHECK
COPYCONTROLFILECOPY...
RMAN>COPYCONTROLFILECOPY
COPYCURRENT...
RMAN>COPYCURRENT
COPYDATAFILE...
RMAN>COPYDATAFILE
?
COPYDATAFILECOPY...
RMAN>COPYDATAFILECOPY
COPYKEEP...
RMAN>COPYKEEP
CREATE
CREATE CATALOG
Create a recovery
catalog or a virtual
private catalog
CREATE[VIRTUAL]CATALOG;
RMAN>CREATECATALOG;
SQL>connrepoomega/oracle1@repos
SQL>SELECTobject_type,COUNT(*)
FROMuser_objects;
RMAN>DROPCATALOG;
SQL>SELECTobject_type,COUNT(*)
FROMuser_objects;
CREATERESTOREPOINT<restore_point_name>
Create a restore point
RMAN>CREATERESTOREPOINTapp_patch;
RMAN>DROPRESTOREPOINTapp_patch;
CREATE SCRIPT
Creates a stored
script called
backup_whole that
backs up the
database and
archived redo logs
Creates a stored
script called
backup_whole that
backs up the
database and
archived redo logs
CREATE[GLOBAL]SCRIPT'<script_name>'
COMMENT'<comment>'
{RMAN_command_list}
FROMFILE'<file_name>'
CREATESCRIPTbackup_whole
COMMENT"backupwholedatabaseandlogs"
{
BACKUPINCREMENTALLEVEL0TAGb_whole_l0
DATABASEPLUSARCHIVELOG;
}
CREATEGLOBALSCRIPTglobal_backup_db
COMMENT"backupanydatabasefromtherecovery
catalog,withlogs"
{
BACKUPDATABASEPLUSARCHIVELOG;
}
CROSSCHECK
Verify the status of backups and copies recorded in the RMAN repository against media such as disk
or tape. The CROSSCHECK command only processes files created on the same device type as the
channels running the crosscheck.
Status
AVAILABLE
Description
The Object is available for use by RMAN. For a backup set to be AVAILABLE, all
set backup pieces must be AVAILABLE.
EXPIRED
Object is not found either in file system (for DISK) or in the media manager (for sbt).
Note that for a backup set to be EXPIRED, all backup pieces in the set must be
EXPIRED. EXPIRED does not mean the same as OBSOLETE.
UNAVAILABLE
Object is not available for use by RMAN. For a backup set to be UNAVAILABLE, all
backup pieces must be UNAVAILABLE.
CROSSCHECK<archivelogRecordSpecifier>
RMAN>RUN{
ALLOCATECHANNELd1FORMAINTENANCEDEVICE
TYPEDISK;
CROSSCHECKARCHIVELOGALL;
RELEASECHANNEL;
}
CROSSCHECK BACKUP
Allocate a channel,
crosscheck backups
in a date range and
release the channel
after use
CROSSCHECKBACKUP....
RMAN>RUN{
ALLOCATECHANNELd1FORMAINTENANCEDEVICE
TYPEDISK;
CROSSCHECKBACKUPDEVICETYPEDISKCOMPLETED
BETWEEN'01JUL08'AND'30SEP08';
RELEASECHANNEL;
}
CROSSCHECK BACKUPPIECE
Checks that specific
backuppieces still
exist
CROSSCHECKBACKUPPIECE....
RMAN>CROSSCHECKBACKUPPIECE
CROSSCHECK BACKUPSET
Checks that specific
backupsets still exist
CROSSCHECKBACKUPSETOF<backupsetidentifier>;
RMAN>CROSSCHECKBACKUPSETOFTABLESPACE
UWDATA;
CROSSCHECK COPY
Checks for the
CROSSCHECKCOPY...
physical existence of
archivelog files and
will change the
V$ARCHIVED_LOG.
STATUS of affected
archivelogs from "A"
for AVAILABLE to "X"
for EXPIRED. Once
the archivelog file has
a status of X, RMAN
will no longer attempt
to backup this
archivelog file.
RMAN>CROSSCHECKCOPYOFARCHIVELOGALL;
CROSSCHECK CONTROLFILECOPY
Checks that specific
controlfile copies still
exist
CROSSCHECKCONTROLFILECOPY....
RMAN>CROSSCHECKCONTROLFILECOPY
CROSSCHECK DATAFILECOPY
Checks that specific
bdatafile copies still
exist
CROSSCHECKDATAFILECOPY<ALL|INTEGER|LIKE|
QUOTED_STRING>
RMAN>CROSSCHECKDATAFILECOPYALL;
CROSSCHECK FOREIGN
CROSSCHECKFOREIGNARCHIVELOG<ALL|FROM|
Crosscheck all foreign HIGH|LOGSEQ|LOW|SCN|SEQUENCE|TIME|
UNTIL>....
archived redo logs
RMAN>CROSSCHECKFOREIGNARCHIVELOGALL;
CROSSCHECK PROXY
Crosscheck the
existence of a specific
proxy copy
CROSSCHECKPROXY
*RMAN>CROSSCHECKPROXY941;
DEBUG
DEBUG<AFFINITY|ALL|DUPLICATE|IO|KRB|
MISC|NODEVALS|OFF|ON|PACKAGES|PLSQL|
RCVCAT|RCVMAN|RECOVER|RESTORE|RESYNC|
RPC|SQL>
*RMAN>DEBUGALL;
*RMAN>DEBUGOFF;
DELETE
To delete physical backups and copies as well as do the following:
Update their repository records in the target control file to status DELETED
Remove their repository records from the recovery catalog (if you use a catalog)
When running RMAN interactively, DELETE displays a list of the files and prompts you for
confirmation before deleting any file in the list. When reading commands from a command file,
RMAN will not prompt for confirmation.
DELETE ARCHIVELOG
Wildcard Delete
DELETEARCHIVELOG<ALL|FROM|HIGH|LIKE|
LOGSEQ|LOW|QUOTED_STRING|SCN|SEQUENCE|
TIME|UNTIL>....
RMAN>LISTARCHIVELOGLIKE'%';
RMAN>CROSSCHECKARCHIVELOGLIKE'%';
RMAN>DELETEARCHIVELOGLIKE'%';
DELETE BACKUPSET
?
Delete Backup Set
*DELETENOPROMPTBACKUPOFDATABASECOMPLETED
BEFORE'SYSDATE7';
?
#backupdatafiletodiskandtape
BACKUPDEVICETYPEDISKDATAFILE1TAG
"weekly_bkup";
BACKUPDEVICETYPEsbtDATAFILE1TAG
"weekly_bkup";
#manuallyallocatediskandsbtchannels
ALLOCATECHANNELFORMAINTENANCEDEVICETYPE
DISK;
ALLOCATECHANNELFORMAINTENANCEDEVICETYPE
SBT;
DELETEBACKUPSETTAG"weekly_bkup";
DELETE EXPIRED
Deletes expired
backup records
DELETE[FORCE|NOPROMPT]EXPIRED
<maintenance_spec>[fordb_unique_name_option];
RMAN>CROSSCHECKBACKUP;
RMAN>DELETEEXPIREDBACKUP;
RMAN>CROSSCHECKBACKUPSETOFTABLESPACEuwdata
DEVICETYPEdiskCOMPLETEDBEFORESYSDATE15;
RMAN>DELETENOPROMPTEXPIREDBACKUPSET
OFTABLESPACEuwdataDEVICETYPEdiskCOMPLETED
BEFORESYSDATE15;
DELETE OBSOLETE
Delete Obsolete
DELETE[FORCE|NOPROMPT]OBSOLETE
[obsOperandList][device_type]
[device_specifier];
RMAN>DELETEFORCEOBSOLETE;
DELETE SCRIPT
Deletes a stored
script b_whole_10
from the recovery
catalog
DELETE[GLOBAL]SCRIPT'<script_name>'
rmanTARGET/CATALOGrman/cat@catdb
RMAN>DELETESCRIPTb_whole_10;
RMAN>DELETEGLOBALSCRIPTb_whole_10;
Drop
DROP CATALOG
Drop the RMAN
catalog
DROPCATALOG;
*SeeCREATECATALOGDemoAbove
DROP DATABASE
Use RMAN to issue
the drop database
command
DROPDATABASE;
NodemoisshownasthisissomethingIwould
stronglyrecommendagainstdoingwithinRMAN.
DROPRESTOREPOINT<restore_point_name>
*SeeCREATERESTOREPOINTDemoAbove
DUPLICATE
Allocates axiliary
channels and
duplicates the target
database as newdb
DUPLICATE[TARGET]DATABASETO<new_name>
LOGFILE'<redo_log_file_path_and_name>'SIZE
<integer><K|M>
[SKIPREADONLY][NOFILENAMECHECK]
RUN{
ALLOCATEAUXILIARYCHANNELd1DEVICETYPE
DISK;
ALLOCATEAUXILIARYCHANNELd2DEVICETYPE
DISK;
DUPLICATETARGETDATABASETOnewdb
LOGFILE
'?/oradata/aux1/redo01.log'SIZE50M,
'?/oradata/aux1/redo02.log'SIZE50M,
'?/oradata/aux1/redo03.log'SIZE50M
SKIPREADONLY
NOFILENAMECHECK;
}
EXIT
Exit from RMAN or a
terminal window
EXIT
RMAN>target/
*RMAN>EXIT;
or
RMAN>HOST;
*$EXIT;
RMAN>
FLASHBACK DATABASE
Returns the database
to its state at a
previous time or SCN
FLASHBACKDATABASETOSCN=<integer>
*RMAN>FLASHBACKDATABASETOSCN=42678315;
GRANT
GRANT<privilege>TO<schema_name>
Grant privileges to a
recovery catalog user
*RMAN>GRANTCATALOGFORDATABASE
orabaseTOrepoomega;
*RMAN>GRANTREGISTERDATABASETOrepoomega;
HOST
Shell out of RMAN to
the operating system
for command
execution
HOST
*SeeEXITDemoAbove
IMPORT
IMPORT CATALOG
Imports the metadata
from one recovery
catalog into a different
recovery catalog
?
?
IMPORT RCVCAT
?
?
?
LIST
LIST<ARCHIVELOG|COPY|DB_UNIQUE_NAME|
Produce a detailed
listing of the indicated
items
FAILURE>ALL;
*RMAN>LISTARCHIVELOGALL;
*RMAN>LISTCOPY;
*RMAN>LISTDB_UNIQUE_NAMEALL;
*ForLISTFAILURESeeAdviseFailureDemoAbove
selectdistinctto_char((b.CHECKPOINT_TIME),
'YYYYMMDDHH:MI.SS')t
fromv$backup_datafileb,v$tablespacets,
v$datafilef
whereb.incremental_level=0
andINCLUDED_IN_DATABASE_BACKUP='YES'
andf.file#=b.file#
andf.ts#=ts.ts#
groupbyb.checkpoint_time
orderby1;
PRINT SCRIPT
Display a stored script
PRINT<IDENTIFIER|QUOTED_STRING>
SeeCREATESCRIPTDemosAbove
PURGE
?
PURGE
See"CREATESCRIPT"DemosAbove
QUIT
Exit the RMAN
executable
QUIT
*RMAN>QUIT;
RECOVER
Apply redo logs and
incremental backups
to datafiles or data
blocks restored from
backup or datafile
copies, in order to
update them to a
specified time
RECOVER
TBD
REGISTER DATABASE
Register a Target in
the Database
Recovery Catalog
REGISTERDATABASE
*RMAN>REGISTERDATABASE;
RELEASE CHANNEL
Release a channel
that was allocated
with an ALLOCATE
CHANNEL command
or ALLOCATE
CHANNEL FOR
MAINTENANCE
command
RELEASECHANNEL
See?DemoAbove
REPAIR FAILURE
Repair one or more
failures recorded in
the automated
diagnostic repository
REPAIRFAILURE[<NO|NOPROMPT|PREVIEW|
USING>
*SeeAdviseFailureDemoAbove
REPLACE SCRIPT
Replace an existing
script stored in the
recovery catalog. If
the script does not
exist, then REPLACE
SCRIPT creates it
REPLACESCRIPT
TBD
REPORT
Perform detailed
analyses on recovery
catalog metadata
REPORT
RMAN>REPORTSCHEMA;
RESET DATABASE
Reset the incarnation
of the target database
in the RMAN
repository to a
previous database
incarnation
RESETDATABASETOINCARNATION
<incarnation_identifier>;
$rmantarget/nocatalog
RMAN>STARTUPNOMOUNT;
RMAN>RESTORECONTROLFILEFROMAUTOBACKUP;
RMAN>ALTERDATABASEMOUNT;
RMAN>LISTINCARNATIONOFDATABASEorabase;
RMAN>RESETDATABASETOINCARNATION1;
RMAN>RESTOREDATABASEUNTILSCN4208974;
RMAN>RECOVERDATABASEUNTILSCN4208974;
RMAN>ALTERDATABASEOPENRESETLOGS;
RMAN>LISTINCARNATIONOFDATABASEorabase;
RESTORE
Restore files from
backup sets or from
disk copies to the
default or a new
location
RESTORE
RMAN>target/catalogrman/rman@rman
RMAN>backupdatabase;
RMAN>validatebackupset1;
SQL>connscott/tiger
SQL>DELETEFROMempWHERErownum<6;
SQL>COMMIT;
RMAN>restoredatabase;
RESYNC
Perform a full resynchronization, which creates a snapshot control file and then copies any new or
changed information from that snapshot control file to the recovery catalog.
This example
performs a full
resynchronization of
the target database
after archiving all
unarchived redo logs
Mount the target
database, update the
repository in the
current control file
with metadata from a
backup control file,
then open the
database
After adding a datafile
to an existing
tablespace
RESYNCCATALOGFROMCONTROLFILECOPY
'<file_name>'
RESYNCFROMDB_UNIQUE_NAMEALL
RESYNCFROMDB_UNIQUE_NAME'<db_unique_name>'
$rmantarget/
RMAN>STARTUPFORCEMOUNT;
RMAN>RESYNCCATALOGFROM
CONTROLFILECOPY'/u01/cfile.dbf';
RMAN>ALTERDATABASEOPEN;
*RMAN>RESYNCCATALOG;
Revoke
Revoke privileges
from a recovery
catalog user
REVOKE
TBD
Run
Execute a script of
RMAN commands
RUN{
<scriptcommands>
}
See"AllocateASingleBackupChannel"Demo
Above
Send
Send a vendor-specific quoted string to one or more specific channels
SEND CHANNEL
Specify commands by
CHANNEL
SENDCHANNEL'<channel_id>''<command_string>'
PARMS'<channel_params>'
TBD
SEND DEVICE_TYPE
Specify a tape drive
for a backup of the
users tablespace to
Oracle Secure
Backup
SENDDEVICE_TYPE'<device_specifier>'
'<command_string>'
PARMS'<channel_params>'
RUN
{
ALLOCATECHANNELc1DEVICETYPEsbt;
SEND'OB_DEVICEstape1';
BACKUPTABLESPACEusers;
}
Set
Set the value of various attributes that affect RMAN behavior for the duration of a RUN block or a
session
?
SET<OFF|ON>[FORALLTABLESPACES]
TBD
SETARCHIVELOGDESTINATIONTO'<
SETBACKUPCOPIES<integer>
SETCOMPRESSIONALGORITHM
'<compression_algorithm_name>'
SETDECRYPTIONIDENTIFIEDBY<password>
SETECHO<ON|OFF>
SETENCRYPTIONALGORITHM'<algorithm_name>'
SETIDENTIFIEDBY<password>[ONLY]
SETMAXCORRUPTFORDATAFILE<dataFileSpec>TO
<integer>
SETNEWNAMEFORDATAFILE<dataFileSpec>TO
'<file_name>'
SETNEWNAMEFORDATAFILE<dataFileSpec>TONEW
SETNEWNAMEFORTEMPFILE<tempFileSpec>TO
'<quoted_string>'
SETNEWNAMEFORTEMPFILE<tempFileSpec>TONEW
SETTORESTOREPOINT<restore_point_name>
SETUNTIL<TIME|SCN>
CONFIGUREARCHIVELOGCOPIESFORDEVICETYPEsbt
TO3;
CONFIGUREDATAFILECOPIESFORDEVICETYPEsbt
TO3;
RMAN>run{
ALLOCATECHANNELdev1DEVICETYPEsbt
PARMS
'ENV=(OB_DEVICE_1=stape1,OB_DEVICE_2=stape2)';
*SETBACKUPCOPIES2;
BACKUPDATABASEPLUSARCHIVELOG;
}
RMAN>run{
SETUNTILTIME="TO_DATE('03/15/08
10:42:07','MM/DD/RRHH24:MI:SS')";
RESTOREDATABASE;
RECOVERDATABASE;
}
?
SETAUXILIARYINSTANCEPARAMETERFILETO
'<file_name>
SETCOMMANDIDTO'<string>'
SETCONTROLFILEAUTOBACKUPFORMATFORDEVICE
TYPE<deviceSpecifier>TO<formatSpec>
SETDBID<integer>
RMAN>RUN{
ALLOCATECHANNELd1DEVICETYPEDISKFORMAT
'/u01/%U';
ALLOCATECHANNELd2DEVICETYPEDISKFORMAT
'/u02/%U';
SETCOMMANDIDTO'rman';
BACKUPINCREMENTALLEVEL0DATABASE;
SQL'ALTERSYSTEMARCHIVELOGCURRENT';
}
RMAN>SETDBID3257174182;
RMAN>STARTUPFORCENOMOUNT;
RMAN>RUN{
ALLOCATECHANNELt1DEVICETYPEsbt;
RESTORESPFILEFROMAUTOBACKUP;
}
STARTUPFORCE;#RMANrestartsdatabasewith
restoredSPFILE
$rmantarget/
RMAN>STARTUPFORCENOMOUNT
RMAN>SETDBID28014364;
RMAN>RUN{
SETCONTROLFILEAUTOBACKUPFORMATFORDEVICE
TYPEDISKTO'/u02/cf_%F.bak';
RESTORECONTROLFILEFROMAUTOBACKUPMAXSEQ
100;
}
ALTERDATABASEMOUNT;
RECOVERDATABASE;
ALTERDATABASEOPENRESETLOGS;
Show
ALL
All
$rmantarget/catalog
repoomega1/oracle1@repos
RMAN>showall;
AUXNAME
Auxname
$rmantarget/catalog
repoomega1/oracle1@repos
RMAN>showauxname;
{DATAFILE|ARCHIVELOG}BACKUPCOPIES
Backup Copies
$rmantarget/catalog
repoomega1/oracle1@repos
RMAN>showdatafilebackupcopies;
RMAN>showarchivelogbackupcopies;
BACKUPOPTIMIZATION
Backup Optimization
$rmantarget/catalog
repoomega1/oracle1@repos
RMAN>showbackupoptimization;
[AUXILIARY]CHANNEL[FORDEVICETYPE
<deviceSpecifier>]
Channel
$rmantarget/catalog
repoomega1/oracle1@repos
RMAN>showchannel;
CONTROLFILEAUTOBACKUP[FORMAT]
$rmantarget/catalog
repoomega1/oracle1@repos
RMAN>showcontrofileautobackup;
CONTROLFILEAUTOBACKUPFORMAT<formatmask>
$rmantarget/catalog
repoomega1/oracle1@repos
RMAN>showcontrofileautobackup;
ENCRYPTIONFORDATABASE
Database Encryption
$rmantarget/catalog
repoomega1/oracle1@repos
RMAN>showencryptionfordatabase;
[DEFAULT]DEVICETYPE
Device Type
$rmantarget/catalog
repoomega1/oracle1@repos
RMAN>showdevicetype;
ENCRYPTIONALGORITHM
Encryption Algorithm
$rmantarget/catalog
repoomega1/oracle1@repos
RMAN>showencryptionalgorithm;
EXCLUDE
Exclude
$rmantarget/catalog
repoomega1/oracle1@repos
RMAN>showexclude;
MAXSETSIZE
$rmantarget/catalog
repoomega1/oracle1@repos
RMAN>showmaxsetsize;
RETENTIONPOLICY
Retention Policy
$rmantarget/catalog
repoomega1/oracle1@repos
RMAN>showretentionpolicy;
RMAN>showretentionpolicytoredundancy;
SNAPSHOTCONTROLFILENAME
Name
$rmantarget/catalog
repoomega1/oracle1@repos
RMAN>SHOWSNAPSHOTCONTROLFILENAME;
Shutdown
Shutdown the target
database
SHUTDOWN<ABORT|IMMEDIATE|NORMAL|
TRANSACTIONAL>
RMAN>SHUTDOWNABORT;
Spool
Write RMAN output to
a log file
SPOOLLOGOFF
SPOOLLOGTO<file_name>[APPEND]
CONFIGUREDEFAULTDEVICETYPETOsbt;
SPOOLLOGTO'/tmp/current_config.log';
SHOWALL;
SPOOLLOGOFF;
SPOOLLOGTO'/home/oracle/rman.log';
BACKUPDATABASE;
SPOOLLOGOFF;
SQL
Execute a SQL
statement from within
RMAN
SQL'<SQL_statement>'
RUN{
SQL'ALTERSYSTEMARCHIVELOGCURRENT';
}
Startup
Startup a Database
STARTUP<DBA|FORCE|MOUNT|NOMOUNT>
STARTUPPFILE'<file_name>'
$rmanTARGET/CATALOGrepoomega/oracle1@repos
RMAN>STARTUPMOUNT;
Switch
Specify that a datafile copy is now the current datafile, that is, the datafile pointed to by the control
file. This command is equivalent to the SQL statement ALTER DATABASE RENAME FILE as it
applies to datafiles
Switch the controlfile
SWITCHDATABASETOCOPY
to point to an
ImageCopy of the
data file
TBD
SWITCHDATAFILE'<data_file_specification>'TO
COPY
TBD
SWITCHDATAFILE'<data_file_specification>'TO
DATAFILECOPY'<file_name>'
TBD
SWITCHDATAFILE'<data_file_specification>'TO
DATAFILECOPYTAG'<tag_name>'
TBD
SWITCHDATAFILEALL
SWITCHTABLESPACE'<tablespace_name>'TOCOPY
RUN{
ALLOCATECHANNELd1DEVICETYPEDISK;
SQL"ALTERTABLESPACEuwdataOFFLINE
IMMEDIATE";
SETNEWNAMEFORDATAFILE
'/u01/oradata/users01.dbf'TO
'/u02/oradata/users01.dbf';
RESTORETABLESPACEuwclass;
SWITCHDATAFILEALL;
RECOVERTABLESPACEuwclass;
SQL"ALTERTABLESPACEuwclassONLINE";
}
SQL"ALTERTABLESPACEusersOFFLINEIMMEDIATE";
SWITCHTABLESPACEusersTOCOPY;
RECOVERTABLESPACEusers;
SQL"ALTERTABLESPACEusersONLINE";
SWITCHTEMPFILE<temp_file_specification>TO
'<file_name>'
TBD
SWITCHTEMPFILEALL
TBD
Transport Tablespace
Create transportable
TRANSPORTTABLESPACE
TBD
Unregister
Unregister a
Database from the
Catalog
UNREGISTERDATABASE'<database_name>'
[NOPROMPT]
RMAN>UNREGISTERDATABASE;
UNREGISTERDB_UNIQUE_NAME'<db_unique_name>'
[INCLUDINGBACKUPS[NOPROMPT]]
RMAN>LISTDB_UNIQUE_NAMEALL;
RMAN>UNREGISTERDB_UNIQUE_NAME'ORADATA';
Upgrade Catalog
Upgrade the recovery
catalog schema from
an older version to
the version required
by RMAN
UPGRADECATALOG
RMAN>UPGRADECATALOG;
Validate
Examine a backup set and report whether its data is intact. RMAN scans all of the backup pieces in
the specified backup sets and looks at the checksums to verify that the contents can be successfully
restored
Validate archivelogs
VALIDATEARCHIVELOGALL
VALIDATEARCHIVELOGLIKE'<string_pattern>'
VALIDATEARCHIVELOGFROMSCN<integer>
VALIDATEARCHIVELOGBETWEENSCN<integer>AND
SCN<integer>
VALIDATEARCHIVELOGUNTILSCN<integer>
VALIDATEARCHIVELOGFROMSEQUENCE<integer>
[THREAD<integer>]
VALIDATEARCHIVELOGSEQUENCE<integer>[THREAD
<integer>]
VALIDATEARCHIVELOGSEQUENCEBETWEEN<integer>
AND<integer>
VALIDATEARCHIVELOGUNTILSEQUENCE<integer>
[THREAD<integer>]
TIMEBETWEEN'<date_string>'AND
'<date_string>'
UNTILTIME'<date_string>'
RMAN>VALIDATEARCHIVELOGALL;
VALIDATEBACKUPSET<primaryKey>
TBD
VALIDATECONTROLFILECOPYALL
VALIDATECONTROLFILECOPY'<file_name>'
VALIDATECONTROLFILECOPYLIKE
'<string_pattern>'
RMAN>VALIDATECONTROLFILECOPYALL;
VALIDATECOPYOFDATABASE
VALIDATECOPYOFDATAFILE'<file_name>'
Validate all database,
datafile, or tablespace VALIDATECOPYOFDATAFILE<file_number>
copies
VALIDATECOPYOFTABLESPACE'<tablespace_name>'
RMAN>VALIDATECOPYOFTABLESPACE'UWDATA';
?
VALIDATE<blockObject>
TBD
VALIDATECURRENTCONTROLFILE
VALIDATEDATABASE
RMAN>VALIDATECURRENTCONTROLFILE;
RMAN>VALIDATEDATABASE;
VALIDATEDATAFILE'<file_name>'
VALIDATEDATAFILE<file_number>
RMAN>VALIDATE
DATAFILE'C:\ORACLE\PRODUCT\ORADATA\ORABASE\UWD
ATA01';
RMAN>VALIDATEDATAFILE9;
VALIDATEDB_RECOVERY_FILE_DEST
VALIDATERECOVERYAREA
VALIDATERECOVERYFILES
VALIDATESPFILE
VALIDATETABLESPACE<tablespace_name_list>
RMAN>VALIDATEDB_RECOVERY_FILE_DEST;
RMAN>VALIDATERECOVERYAREA;
RMAN>VALIDATERECOVERYFILES;
RMAN>VALIDATESPFILE;
RMAN>VALIDATETABLESPACEuwdata;
RMAN Demos
Using a target
database controlfile
RMAN>CONFIGURERETENTIONPOLICYTOREDUNDANCY
1;
instead of recovery
catalog
The following were
provided to PSOUG
by member Andrea
Sparling
Incremental Level 0
Backup
RMAN>CONFIGUREBACKUPOPTIMIZATIONOFF;#
default
RMAN>CONFIGUREDEFAULTDEVICETYPETODISK;#
default
RMAN>CONFIGURECONTROLFILEAUTOBACKUPOFF;#
default
RMAN>CONFIGURECONTROLFILEAUTOBACKUPFORMAT
FORDEVICETYPEDISK
TO'%F';
RMAN>CONFIGUREDEVICETYPEDISKPARALLELISM1
BACKUPTYPETO
COMPRESSEDBACKUPSET;#default
RMAN>CONFIGUREDATAFILEBACKUPCOPIESFOR
DEVICETYPEDISKTO1;
RMAN>CONFIGUREARCHIVELOGBACKUPCOPIESFOR
DEVICETYPEDISKTO1;
RMAN>CONFIGUREMAXSETSIZETO2G;
RMAN>CONFIGUREARCHIVELOGDELETIONPOLICYTO
NONE;
RMAN>CONFIGURESNAPSHOTCONTROLFILENAMETO
'/u01/app/oracle/product/10.1.0.3/dbs/snapcf_pn
bdb.f';
RMAN>connecttarget/
RMAN>BACKUPINCREMENTALLEVEL0
TAGfull_backup
FORMAT'/u03/backup/rman_fullbackup_%d_
%t.%s.%c.%p.bus'
DATABASE;
RMAN>COPYCURRENTCONTROLFILETO
'/u03/backup/ctrlfile.backup';
RMAN>CROSSCHECKBACKUP;
RMAN>CROSSCHECKARCHIVELOGALL;
RMAN>DELETEOBSOLETE;
RMAN>DELETEEXPIREDARCHIVELOGALL;
RMAN>LISTBACKUP;
RMAN>LISTARCHIVELOGALL;
Incremental
#!/bin/sh
###############################################
######
#scripttotakearmanfullbackup
#thisscriptmustberun
#asthetrusteduser'oracle10g''oracle9i'
etc
###############################################
######
#create output logs with that number and the current date in the ./rman/logs
directory age out in 14-30 days
#get env IMPORTANT, if multiple Oracle SID's the env var ORACLE_SID
must be set
./etc/bashrc
exportORACLE_BASE=/u01/app/oracle;
export
ORACLE_HOME=$ORACLE_BASE/product/10.1.0.3;
exportORACLE_SID=pnbdb;
export
LD_LIBRARY_PATH=/u01/app/oracle/product/10.1.0.
3/lib:/lib:/usr/lib;
#setrelativeheadofdirectory(workdiskis
u03,oraclediskisu01)
HEAD=/u03
WORK=$HEAD/backup/scripts
cd$WORK
#uniquelogfile
DATE=`date+"%Y%m%d%H%M%S"`
LOGFILE='/u03/backup/rman/logs/rman_full_backup
_'${DATE}'.log'
echo"log:"${LOGFILE}>$LOGFILE
echo"Started">>$LOGFILE
date>>$LOGFILE
echoinstance$ORACLE_SID>>$LOGFILE
###############################################
###########################
${ORACLE_HOME}/bin/rman@${WORK}/rman_full.rcv
>>$LOGFILE
returncode=$?
echo$returncodereturncode>>$LOGFILE
df>>$LOGFILE
echo"Ended">>$LOGFILE
date>>$LOGFILE
if[$returncodene0];then
echo"emailerrorlog">>$LOGFILE
mailcsds_opb@u.washington.edus"RMANERROR
LOGforparnassuspnbdbbackup"<$LOGFILE
mailamspar@u.washington.edus"RMANERROR
LOGforparnassuspnbdbbackup"<$LOGFILE
fi
exit
RAC Demo
Crosschecking on Multiple Nodes of an Oracle Real Application Clusters Configuration: Example In
this example, you perform a crosscheck of backups on two nodes of an Oracle Real Application
Clusters configuration, where each node has access to a subset of backups. It is assumed here that
all backups are accessible by at least one of the two nodes used in the crosscheck. Any backups not
accessible from at least one of the nodes are marked EXPIRED after the crosscheck.
RMAN on a RAC
Cluster
ALLOCATECHANNELFORMAINTENANCEDEVICETYPE
DISKCONNECT'sys/oracle1@inst1';
ALLOCATECHANNELFORMAINTENANCEDEVICETYPE
DISKCONNECT'sys/oracle1@inst2';
CROSSCHECKBACKUP;
SELECTrecovery_estimated_ios,
actual_redo_blks,target_redo_blks,
target_mttr,estimated_mttr
FROMgv$instance_recovery;
SELECT*FROMv_$recovery_file_dest;
SELECTCOUNT(*)FROMdba_hist_instance_recovery
;
cd/app/oracle/product/OracleHomes/oradata/orcl
lsla
cd
/app/oracle/product/OracleHomes/admin/orcl/bdum
p
tailalert_orcl.log
rmcontrol02.ctl
lsla
SQL>connhr/hr(afterunlockingaccount)
SQL>descjobs
SQL>INSERTINTOjobsVALUES(987,'TEST',0,1);
SQL>COMMIT;
alsobuildadummytable
tailalert_orcl.log
nooneknowsanythingbadhashappened
SQL>selectfile_namefrom
mgmt$db_controlfiles;
letsdoashutdownandrestart
SQL>shutdownimmediate;
SQL>conn/assysdba
Connected.
SQL>shutdownimmediate;
ORA00210:cannotopenthespecifiedcontrol
file
ORA00202:controlfile:
'/app/oracle/product/OracleHomes/oradata/orcl/c
ontrol02.ctl'
ORA27041:unabletoopenfile
LinuxError:2:Nosuchfileordirectory
Additionalinformation:3
nowwehaveaproblem
SQL>shutdownabort;
tailthealertlogandweknowwhathappened
RUN{
STARTUPFORCENOMOUNT;
RESTORECONTROLFILE;
DATABASEMOUNT;
RESTOREDATABASE;
RECOVERDATABASE;
}
alterdatabaseopenresetlogs;
lslashowscontrolfilesback
rmandone
hadn'tdoneabackupafterlastrestore
RMAN>run{startupforcenomount;restore
controlfile;
alterdatabasemount;}
tailthealertlog
lookat/app/oracle/OracleHomes/oradata/orcl
thefileisrestored
lsla
conn/assysdba
shutdownimmediate;
startup
noteerrormessage
SQL>startup
ORACLEinstancestarted.
TotalSystemGlobalArea440401920bytes
FixedSize1219880bytes
VariableSize130024152bytes
DatabaseBuffers306184192bytes
RedoBuffers2973696bytes
Databasemounted.
ORA01589:mustuseRESETLOGSorNORESETLOGS
option
fordatabaseopen
SQL>startupmount;
tailalert_orcl.log
nextdumpedcontrolfiles1and3
shutdownimmediatefails
shutdownabort
connecttoRMAN
Backup and Recovery Practices Best Practices
Metalink Note:
388422.1
dest
REASON: If an archivelog is corrupted or lost, by having multiple copies in
multiple locations, the other logs will still be available and could be used.
If an online log is deleted or becomes corrupt, you will have another member
that can be used to recover if required.
SQL>altersystemset
log_archive_dest_2='location=/new/location/archive2'
scope=both;
SQL>alterdatabaseaddlogfilemember
'/new/location/redo21.log'togroup1;
4. When backing up the database use the 'check logical' parameter
REASON: This will cause RMAN to check for logical corruption within a block
as well as the normal
head/tail checksumming. This is the best way to ensure that you will get a
good backup.
RMAN>backupchecklogicaldatabaseplusarchivelog
deleteinput;
5. Test your backup
REASON: This will do everything except actually restore the database. This is
the best method to determine if your backup is good and usable before being
in a situation where it is
critical and issues exist.
RMAN>restorevalidatedatabase;
6. Have each datafile in a single backup piece
REASON: When doing a partial restore RMAN must read through the entire
piece to get the
datafile/archivelog requested. The smaller the backup piece the quicker the
restore can
complete. This is especially relevent with tape backups of large databases or
where the
restore is only on indiviDUAL / few files.
RMAN>backupdatabasefilesperset1plusarchivelog
deleteinput;
7. Maintain your RMAN catalog/controlfile
REASON: Choose your retention policy carefully. Make sure that it
compliments your tape subsystem
retention policy, requirements for backup recovery strategy. If not using a
catalog, ensure that your controlfile record keep time instance parameter
matches your retention policy.
SQL>altersystemsetcontrol_file_record_keep_time=21
scope=both;
This will keep 21 days of backup records.
Run regular catalog maintenance.
REASON: Delete obsolete will remove backups that are outside your
retention policy. If obsolete backups are not deleted, the catalog will continue
to grow until performance becomes an issue.
RMAN>deleteobsolete;
REASON: crosschecking will check that the catalog/controlfile matches the
physical backups. If a backup is missing, it will set the piece to 'EXPIRED' so
when a restore is started, that it will not be eligible, and an earlier backup will
be used. To remove the expired backups from the catalog/controlfile use the
delete expired command.
RMAN>crosscheckbackup;
RMAN>deleteexpiredbackup;
8. Prepare for loss of controlfiles set autobackup on
REASON: This will ensure that you always have an up to date controlfile
available that has been taken at the end of the current backup not during.
RMAN>configurecontrolfileautobackupon;
keep your backup logs
REASON: The backup log contains parameters for your tape access,
locations on controlfile backups that can be utilised if complete loss occurs.
9. Test your recovery
REASON: During a recovery situation this will let you know how the recovery
will go without actually doing it, and can avoid having to restore source
datafiles again.
SQL>recoverdatabasetest;
10. Do not specify 'delete all input' when backing up archivelogs
REASON: Delete all input' will backup from one destination then delete both
copies of the archivelog where as 'delete input' will backup from one location
and then delete what has been backed up. The next backup will back up
those from location 2 as well as new logs from location 1, then delete all that
are backed up. This means that you will have the archivelogs since the last
backup available on disk in location 2 (as well as backed up once) and two
copies backup up prior to the previous backup.