General |
Note:$ORACLE_HOME/rdbms/admin/prgrmanc.sql |
Encryption Algorithms |
col algorithm_name format a15
col algorithm_description format a25
SELECT * FROM gv$rman_encryption_algorithms;
The default encryption algorithm is 128-bit AES. |
Data Dictionary Objects |
DBA_HIST_INSTANCE_RECOVERY |
GV_$RECOVERY_STATUS |
DBA_RECOVERABLE_SCRIPT |
V_$FLASH_RECOVERY_AREA_USAGE |
DBA_RECOVERABLE_SCRIPT_BLOCKS |
V_$INSTANCE_RECOVERY |
DBA_RECOVERABLE_SCRIPT_ERRORS |
V_$RECOVER_FILE |
DBA_RECOVERABLE_SCRIPT_PARAMS |
V_$RECOVERY_FILE_DEST |
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 Directives
|
Format |
Description |
%a |
Current database activation id |
%A |
Zero-filled activation ID |
%c |
The copy number of the backup piece within a set of duplexed backup
pieces.bMaximum value is 256 |
%d |
Database name |
%D |
Current day of the month from the Gregorian calendar in format DD |
%e |
Archived log sequence number |
%f |
Absolute file number |
%F |
Combines the DBID, day, month, year, and sequence into a unique and repeatable
generated name |
%h |
Archived redo log thread number |
%I |
DBID |
%M |
Month in the Gregorian calendar in the format MM |
%n |
Database name, padded on the right with x characters to a total length of
eight characters |
%N |
Tablespace name. Only valid when backing up datafiles as image copies. |
%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 |
Zero-filled sequence number |
%t |
Backup set time stamp, a 4-byte value derived as the number of seconds elapsed
since a fixed reference time. The combination of %s and %t can be used to form a unique name for the backup
set. |
%T |
Year, month, and day in the Gregorian calendar in the format: YYYYMMDD |
%u |
An 8-character name constituted by compressed representations of the backup
set or image copy number and the time the backup set or image copy was created |
%U |
A system-generated unique filename (default). %U is different for image copies
and backup pieces. For a backup piece, %U is a shorthand for %u_%p_%c and guarantees uniqueness in generated
backup filenames. For an image copy of a datafile, %U means the following:
data-D-%d_id-%I_TS-%N_FNO-%f_%u
For an image copy of an archived redo log, %U means the following:
arch-D_%d-id-%I_S-%e_T-%h_A-%a_%u
For an image copy of a control file, %U means the following:
cf-D_%d-id-%I_%u |
%Y |
Year in this format: YYYY |
%% |
Percent (%) character. For example, %%Y translates to the string %Y |
|
Repository Initialization Parameters |
compatible=10.2.0
log_archive_format=RMAN_%s_%r_%d.arc
remote_login_passwordfile=SHARED
|
show parameter archive_format |
To create a permanent NAS Mount |
-- as root
$ unmount /mnt
$ mkdir /u01
$ chown oracle:dba /u01
$ chmod 755 /u01
$ cd /etc
$ vi fstab
192.168.2.200:/vol/vol1/alpha1 /u01 nfs rw,bg,intr,hard,rsize=32768,wsize=32768,noac,nolock,tcp,vers=3 0 0 |
Create RMAN Repository and Catalog |
/* as Linux user oracle modify the TNSNAMES.ORA to point to
the database that will host the repository catalog: Then ... */
$ sqlplus / as sysdba
-- using OMF
SQL> CREATE TABLESPACE cat_tbs;
SQL> CREATE USER repoomega
IDENTIFIED BY oracle1
DEFAULT TABLESPACE cat_tbs
TEMPORARY TABLESPACE temp
QUOTA UNLIMITED ON cat_tbs;
RMAN> GRANT create session TO repoomega
RMAN> GRANT recovery_catalog_owner TO repoomega;
RMAN> GRANT execute ON dbms_stats TO repoomega; -- for demos
-- in the operating system shell
$ rman target / catalog repoomega/oracle1@repos
RMAN> create catalog tablespace cat_tbs;
RMAN> register database;
RMAN> report schema;
RMAN> configure default device type to disk;
RMAN> configure device type disk parallelism 2 backup type to copy;
RMAN> configure retention policy to recovery window of 7 days;
RMAN> configure backup optimization on; |
Put the database into ARCHIVELOG mode |
/* as Linux user oracle modify the TNSNAMES.ORA to point
to the database that will host the repository catalog: Then ... */
$ sqlplus / as sysdba
col name format a30
col value format a30
SELECT name, value
FROM gv$parameter
WHERE name LIKE '%arch%';
-- alter the SPFILE as required
shutdown immediate;
startup mount;
alter database archivelog;
alter database open;
archive log list;
alter system switch logfile;
archive log list; |
RMAN> BACKUP TAG
Q107 DATABASE KEEP FOREVER; |
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> |
rman TARGET / @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. |
ADVISE FAILURE <ALL | CRITICAL | HIGH | LOW | failure_number_list>
EXCLUDE FAILURE <failure_number_list> |
RMAN> LIST FAILURE;
RMAN> ADVISE FAILURE ALL;
RMAN> REPAIR FAILURE; |
|
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>, DEVICE
TYPE <device_type_name>[allocation_operand_list] |
SQL> desc gv$backup_device
SQL>
SELECT *
FROM gv$backup_device;
RMAN> RUN
{
ALLOCATE CHANNEL d1 DEVICE TYPE DISK
FORMAT '/u01/backups/%U';
BACKUP DATABASE PLUS ARCHIVELOG;
RELEASE CHANNEL;
} |
Allocates a tape channel for a whole database and archived redo log backup |
RMAN RUN
{
ALLOCATE CHANNEL tape1 DEVICE TYPE sbt;
BACKUP DATABASE PLUS ARCHIVELOG;
RELEASE CHANNEL;
} |
Spread the backup across several disk drives. Allocate one DEVICE TYPE DISK channel for ach disk drive and specify the format string so that the filenames are on different
disks |
RUN
{
ALLOCATE CHANNEL d1 DEVICE TYPE DISK FORMAT
'/u01/backups/%U';
ALLOCATE CHANNEL d2 DEVICE TYPE DISK FORMAT
'/u02/backups/%U';
BACKUP DATABASE PLUS ARCHIVELOG;
RELEASE CHANNEL;
} |
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 |
RUN {
ALLOCATE CHANNEL c1 DEVICE TYPE DISK MAXPIECESIZE 5M;
# AS COPY is the default, so RMAN creates image copies
BACKUP DATABASE PLUS ARCHIVELOG;
SET BACKUP COPIES = 2;
BACKUP DATAFILE 1 FORMAT '/u01/backups/%U', '/u02/backups/%U';
} |
Allocate Maintenance Channel |
*Allocates a channel in preparation for a CHANGE, DELETE, or CROSSCHECK.
This cannot be used within a RUN block. |
ALLOCATE CHANNEL FOR MAINTENANCE DEVICE TYPE <device_specifier>
[allocation_operand_list]; |
RMAN> ALLOCATE CHANNEL FOR
MAINTENANCE DEVICE TYPE DISK;| |
|
ALTER CLONE |
? |
ALTER CLONE .... |
TBD |
|
ALTER DATABASE |
Mount and open the database |
ALTER DATABASE <MOUNT | OPEN | OPEN RESETLOGS>; |
RMAN> STARTUP NOMOUNT;
RMAN> ALTER DATABASE MOUNT;
RMAN>
BACKUP DATABASE;
RMAN>
ALTER DATABASE OPEN; |
Mount and open the database resetlogs |
RUN {
ALLOCATE CHANNEL ch1 DEVICE TYPE sbt;
SET UNTIL SCN 1024;
RESTORE DATABASE;
RECOVER DATABASE;
ALTER DATABASE OPEN RESETLOGS;
} |
|
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>' CHECK LOGICAL COPIES <integer>
CUMULATIVE DEVICE TYPE <deviceSpecifier> DISKRATIO <integer> DURATION
<FileNameConversionSpecification> FILERPERSET <integer> FORCE
< AUXILIARY FORMAT <formatSpec, NEW> | FORMAT <formatSpec>
<forRecoveryOfSpec>
FULL
<keep option>
MAXSETSIZE <sizeSpec>
<notBackedUpSpec>
NO CHECKSUM NO EXCLUDE POOL <integer> PROXY [ONLY] REUSE SECTION SIZE <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>' CHECK LOGICAL COPIES <integer>
CUMULATIVE DEVICE TYPE <deviceSpecifier> DISKRATIO <integer> DURATION
<FileNameConversionSpecification> FILERPERSET <integer> FORCE
< AUXILIARY FORMAT <formatSpec, NEW> | FORMAT <formatSpec>
<forRecoveryOfSpec>
INCREMENTAL <LEVEL | FROM SCN> <integer>
<keep option>
MAXSETSIZE <sizeSpec>
<notBackedUpSpec>
NO CHECKSUM NO EXCLUDE POOL <integer> PROXY [ONLY] REUSE SECTION SIZE <sizeSpec> <skipSpec>
TAG '<tag_name>' VALIDATE |
BACKUP ARCHIVELOG |
Backs up copy of each distinct log sequence number |
BACKUP ARCHIVELOG <ALL | ...> .... |
RMAN> BACKUP ARCHIVELOG ALL; |
BACKUP AUXILIARY |
? |
BACKUP AUXILIARY .... |
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. |
BACKUP AS BACKUPSET DEVICE TYPE <device_identifier> COPIES
<integer>
DATABASE FORMAT '<location_and_format>' .... |
BACKUP AS BACKUPSET
(DATAFILE 3, 4, 5, 6, 7) (DATAFILE 8, 9);
BACKUP AS BACKUPSET DATAFILE 3, 4, 5, 6, 7, 8, 9; |
BACKUP AS COMPRESSED BACKUPSET |
Create two copies of a compressed
backupset. |
BACKUP AS COMPRESSED BACKUPSET DEVICE TYPE <device_identifier>
COPIES <integer>
DATABASE FORMAT '<location_and_format>' |
BACKUP AS COMPRESSED
BACKUPSET DEVICE TYPE DISK COPIES 2
DATABASE FORMAT '/u01/db_%U', '/u02/db_%U'; |
BACKUP AS COPY |
Backing up as an image copy |
BACKUP AS COPY <backup_specification> .... |
RUN {
ALLOCATE CHANNEL dev1 DEVICE TYPE DISK FORMAT '/u01/%U';
ALLOCATE CHANNEL dev2 DEVICE TYPE DISK FORMAT '/u02/%U';
BACKUP AS COPY TABLESPACE system, tools, users, undotbs;
BACKUP AS COPY CURRENT CONTROLFILE;
} |
BACKUP BLOCKS |
? |
BACKUP BLOCKS .... |
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 |
BACKUP CHANNEL '<channel_id>' .... |
RUN {
ALLOCATE CHANNEL d2 DEVICE TYPE DISK
PARMS='ENV=(NSR_DATA_VOLUME_POOL=first_copy)';
ALLOCATE CHANNEL d1 DEVICE TYPE DISK
PARMS='ENV=(NSR_DATA_VOLUME_POOL=second_copy)';
BACKUP CHANNEL d1 ARCHIVELOG UNTIL TIME 'SYSDATE'
NOT BACKED UP 2 TIMES TAG SECOND_COPY;
BACKUP CHANNEL d2 ARCHIVELOG UNTIL TIME 'SYSDATE'
NOT BACKED UP 2 TIMES TAG FIRST_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. |
BACKUP CHECK [LOGICAL] <database_specifications> |
RUN {
SET MAXCORRUPT FOR DATAFILE 5,6,7,8 TO 1;
BACKUP CHECK LOGICAL DATABASE;
} |
BACKUP CONTROLFILECOPY |
? |
BACKUP CONTROLFILECOPY .... |
TBD |
BACKUP COPY |
? |
BACKUP COPY .... |
TBD |
BACKUP COPIES |
Define the number of backup copies to create |
BACKUP COPIES <integer> .... |
RUN {
BACKUP COPIES 2 DEVICE TYPE sbt BACKUPSET ALL;
} |
BACKUP CUMMULATIVE |
? |
BACKUP CUMMULATIVE .... |
TBD |
BACKUP CURRENT |
Backup the current Control File to the default or specified location |
BACKUP CURRENT CONTROLFILE [TO DESTINATION <destination_path>]; |
RUN {
BACKUP CURRENT CONTROLFILE TO DESTINATION '/u01/backups';
} |
BACKUP DATABASE |
Backup Database |
RUN
{
ALLOCATE CHANNEL d1 DEVICE TYPE DISK;
BACKUP DATABASE;
} |
Backup Database Plus Archivelog |
RUN
{
ALLOCATE CHANNEL d1 DEVICE TYPE DISK;
BACKUP DATABASE PLUS ARCHIVELOG;
} |
BACKUP DATAFILE |
Datafile backup to multiple locations |
BACKUP DATAFILE <integer> [FORMAT '<location_and_name_format>']
BACKUP DATAFILE <integer> [TO '<location>'] |
RUN {
ALLOCATE CHANNEL d1 DEVICE TYPE DISK;
BACKUP DATAFILE 1 FORMAT '/u01/backups/%U', '/u02/backups/%U';
BACKUP DATAFILE 6 TO '/u01/backups', '/u02/backups';
} |
BACKUP DATAFILECOPY |
? |
BACKUP DATAFILECOPY .... |
TBD |
BACKUP DB_FILE_NAME_CONVERT |
? |
BACKUP DB_FILE_NAME_CONVERT .... |
TBD |
BACKUP DB_RECOVERY_FILE_DEST |
? |
BACKUP DB_RECOVERY_FILE_DEST .... |
TBD |
BACKUP DEVICE TYPE |
RMAN locates all datafile copies with the tag
LATESTCOPY, backs them up to tape, and names the backups by means of substitution variables. After the datafile
copies are on tape, the example deletes all image copies with the tag LATESTCOPY. |
BACKUP DEVICE TYPE <DISK | SBT> .... |
RMAN> {
BACKUP DEVICE TYPE sbt
DATAFILECOPY FROM TAG 'LATESTCOPY' FORMAT 'Datafile%f_Database%d';
DELETE COPY TAG 'LATESTCOPY';
} |
BACKUP DISKRATIO |
Populate each backup set with
datafiles from the specified number of disks. To disable set
to 0. |
RMAN> BACKUP
DISKRATIO 0; -- disable
RMAN> BACKUP DISKRATIO 5; -- enable |
BACKUP DURATION |
Backup will stop if it is not completed in the specified
duration |
BACKUP DURATION <HH:MI> <backup_specification> [MINIMIZE <LOAD | TIME>]
BACKUP DURATION <HH:MI> <backup_specification> PARTIAL |
RMAN> BACKUP DURATION 3:30
DATABASE; |
BACKUP FILE |
? |
BACKUP FILE .... |
TBD |
BACKUP FILESPERSET |
? |
BACKUP FILESPERSET .... |
TBD |
BACKUP ... FOR RECOVER OF ... |
This command will give me a level 1 backup to be used to
recover level 0 backup to the latest level |
BACKUP ... FOR RECOVER OF COPY WITH TAG .... |
RMAN > BACKUP INCREMENTAL LEVEL
1 FOR RECOVER OF COPY WITH TAG 'incr_upd' DATABASE FORMAT
'/oradata/rman/161932/inc_%d_%T_%t_%s_%p'; |
Alters the RECOVER COPY... WITH TAG to perform incomplete recovery of
the datafile copies to the point in time in the past where you want your window of recoverability to begin. Maintain a 7 day window. |
RUN {
RECOVER COPY OF DATABASE WITH TAG 'incr_update' UNTIL TIME 'SYSDATE-7';
BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG
'incr_upd'
DATABASE;
} |
BACKUP FORCE |
Forces RMAN to ignore backup optimization even
if CONFIGURE BACKUP OPTIMIZATION is ON |
BACKUP FORCE <backup_specification> |
RMAN> BACKUP FORCE DATABASE; |
BACKUP FORMAT |
Specify Backup Format |
BACKUP FORMAT <format_specification> .... |
RMAN> BACKUP FORMAT =
'UW_%d/%t/%s/%p' ARCHIVELOG LIKE '%arc_dest%'; |
BACKUP FROM |
? |
BACKUP FROM .... |
TBD |
BACKUP FULL |
Creates a backup of all blocks of datafiles included in the
backup |
BACKUP FULL |
RMAN> BACKUP FULL; |
BACKUP INCREMENTAL |
Incremental Backup Level 0 |
BACKUP INCREMENTAL LEVEL <level_number> [CUMULATIVE | DIFFERENTIAL> .... |
BACKUP INCREMENTAL LEVEL 0 DATABASE; |
Incremental Backup Level 1
Run to back up blocks that have changed since most recent level 0 or 1 |
BACKUP INCREMENTAL LEVEL 1 CUMULATIVE DATABASE;
BACKUP INCREMENTAL LEVEL 1 DIFFERENTIAL TABLESPACE users;
BACKUP INCREMENTAL LEVEL 1 CUMULATIVE SKIP INACCESSIBLE DATABASE; |
Copies two datafiles and exempts them from the retention policy forever |
BACKUP KEEP <FOREVER | UNTIL TIME 'date_string' [RESTORE POINT
<restore_point_name>] |
RMAN> SHUTDOWN IMMEDIATE;
RMAN> STARTUP MOUNT;
RMAN> BACKUP KEEP FOREVER FORMAT '?/dbs/%U_longterm.cpy'
TAG LNGTRM_BCK DATAFILE 5 DATAFILE 6;
RMAN> ALTER DATABASE OPEN; |
BACKUP KEEP |
? |
BACKUP KEEP .... |
TBD |
BACKUP MAXSETSIZE |
? |
BACKUP MAXSETSIZE .... |
TBD |
BACKUP NOCHECKSUM |
? |
BACKUP NOCHECKSUM .... |
TBD |
BACKUP NOEXCLUDE |
? |
BACKUP NOEXCLUDE .... |
TBD |
BACKUP NOKEEP |
? |
BACKUP NOKEEP .... |
TBD |
BACKUP NOT |
? |
BACKUP NOT .... |
TBD |
BACKUP PROXY |
? |
BACKUP PROXY .... |
TBD |
BACKUP POOL |
? |
BACKUP POOL .... |
TBD |
BACKUP RECOVERY |
? |
BACKUP RECOVERY .... |
TBD |
BACKUP REUSE |
? |
BACKUP REUSE .... |
TBD |
BACKUP SECTION |
? |
BACKUP SECTION .... |
TBD |
BACKUP SETSIZE |
? |
BACKUP SETSIZE .... |
TBD |
BACKUP SKIP READONLY |
? |
BACKUP SKIP READONLY .... |
TBD |
BACKUP SPFILE |
Backup the Server Parameter file to the default or specified location |
BACKUP SPFILE [TO DESTINATION <destination_path>] |
RMAN> BACKUP SPFILE TO
DESTINATION '/u01/backups'; |
BACKUP TAG |
Backup the database and apply a user specified tag |
BACKUP TAG '<tag_name>' .... |
RMAN> BACKUP TAG
'weekly_full_db_bkup' DATABASE MAXSETSIZE 10M; |
BACKUP TABLESPACE |
? |
BACKUP TABLESPACE .... |
TBD |
BACKUP TO |
? |
BACKUP TO .... |
TBD |
BACKUP VALIDATE |
? |
BACKUP VALIDATE .... |
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:
- I/O errors causing minor data loss
- Memory corruptions that get flushed to disk
|
BLOCKRECOVER ALLOW |
? |
BLOCKRECOVER ALLOW .... |
TBD |
BLOCKRECOVER ARCHIVELOG |
? |
BLOCKRECOVER ARCHIVELOG .... |
TBD |
BLOCKRECOVER AUXILIARY |
? |
BLOCKRECOVER AUXILIARY .... |
TBD |
BLOCKRECOVER CHECK |
? |
BLOCKRECOVER CHECK .... |
TBD |
BLOCKRECOVER CLEAR |
? |
BLOCKRECOVER CLEAR .... |
TBD |
BLOCKRECOVER COPY |
? |
BLOCKRECOVER COPY .... |
TBD |
BLOCKRECOVER CORRUPTION |
? |
BLOCKRECOVER CORRUPTION .... |
TBD |
BLOCKRECOVER DATABASE |
? |
BLOCKRECOVER DATABASE .... |
TBD |
BLOCKRECOVER DATAFILE |
Recover corrupt blocks in 3 data files |
BLOCKRECOVER DATAFILE <data_file_number> BLOCK <block_list> |
RMAN> BLOCKRECOVER DATAFILE 2 BLOCK 12,13;
RMAN> BLOCKRECOVER DATAFILE 2 BLOCK 12,13 DATAFILE 3
BLOCK 5,98,99
DATAFILE 4 BLOCK 19; |
Limit block recovery by restoration type |
BLOCKRECOVER DATAFILE <data_file_number> BLOCK <block_list>
TABLESPACE <tablespace_name> FROM DATAFILECOPY |
RUN {
BLOCKRECOVER DATAFILE 3 BLOCK 2,3,4,5 TABLESPACE sales DBA 4194405, 4194409, 4194412
FROM DATAFILECOPY;
} |
BLOCKRECOVER DATAFILECOPY |
? |
BLOCKRECOVER DATAFILECOPY .... |
TBD |
BLOCKRECOVER DELETE |
? |
BLOCKRECOVER DELETE .... |
TBD |
BLOCKRECOVER DEVICE |
? |
BLOCKRECOVER DEVICE .... |
TBD |
BLOCKRECOVER EXCLUDE |
? |
BLOCKRECOVER EXCLUDE .... |
TBD |
BLOCKRECOVER FROM |
? |
BLOCKRECOVER FROM .... |
TBD |
BLOCKRECOVER NOFILE UPDATE |
? |
BLOCKRECOVER NOFILE UPDATE .... |
TBD |
BLOCKRECOVER NOPARALLEL |
? |
BLOCKRECOVER NOPARALLEL .... |
TBD |
BLOCKRECOVER NOREDO |
? |
BLOCKRECOVER NOREDO .... |
TBD |
BLOCKRECOVER PARALLEL |
? |
BLOCKRECOVER PARALLEL .... |
TBD |
BLOCKRECOVER PREVIEW |
? |
BLOCKRECOVER PREVIEW .... |
TBD |
BLOCKRECOVER RESTORE |
? |
BLOCKRECOVER RESTORE .... |
TBD |
BLOCKRECOVER SAVE |
? |
BLOCKRECOVER SAVE .... |
TBD |
BLOCKRECOVER SKIP READONLY |
? |
BLOCKRECOVER SKIP READONLY .... |
TBD |
BLOCKRECOVER SAVE |
? |
BLOCKRECOVER SAVE .... |
TBD |
BLOCKRECOVER TABLESPACE |
Limit block recovery by backup tag |
BLOCKRECOVER TABLESPACE <tablespace_name> ... |
BLOCKRECOVER TABLESPACE SYSTEM DBA 4194404, 4194405
FROM TAG "weekly_backup"; |
Limit block recovery by time |
BLOCKRECOVER TABLESPACE <tablespace_name> ... |
BLOCKRECOVER TABLESPACE SYSTEM DBA 4194404, 4194405
RESTORE UNTIL TIME 'SYSDATE-2'; |
Repair all corrupt blocks in the database using gv$database_block_corruption |
BLOCKRECOVER CORRUPTION LIST |
BACKUP VALIDATE DATABASE;
BLOCKRECOVER CORRUPTION LIST; |
BLOCKRECOVER TEST |
? |
BLOCKRECOVER TEST .... |
TBD |
BLOCKRECOVER UNDO |
? |
BLOCKRECOVER UNDO .... |
TBD |
BLOCKRECOVER VALIDATE |
? |
BLOCKRECOVER VALIDATE .... |
TBD |
|
CATALOG |
Adds information about file copies and user-managed backups to the
repository |
CATALOG ARCHIVELOG |
Back the named archive log |
CATALOG ARCHIVELOG '<file_name_list>' |
RMAN> CATALOG ARCHIVELOG ' |
CATALOG BACKUP |
Catalogs the backups specified |
CATALOG BACKUP ... |
RMAN> CATALOG BACKUP ... |
CATALOG BACKUPPIECE |
Catalogs the backup pieces in the new location |
CATALOG BACKUPPIECE <file_name_list> |
RMAN> CATALOG BACKUPPIECE
'/u01/c-874220581-20080315-01'; USING
target database control file instead of recovery catalog
cataloged backup piece backup piece
handle=/u01/c-874220581-20080315-01 RECID=8
STAMP=607695990; |
CATALOG CLONE |
? |
CATALOG CLONE ... |
TBD |
CATALOG CONTROLFILECOPY |
Catalog the control files identified |
CATALOG CONTROLFILECOPY <controlfilecopy_name_list> |
RMAN> COPY CURRENT CONTROLFILE TO '/stage';
RMAN> CATALOG CONTROLFILECOPY '/stage/control01.ctl' |
CATALOG DATAFILECOPY |
Specifies that the datafile copy should be
recorded as a level 0 incremental backup (0 is the only valid value of LEVEL) |
DATAFILECOPY <file_name_list> LEVEL <integer> |
RMAN> CATALOG DATAFILECOPY
'/stage/users01.dbf';
RMAN> CATALOG DATAFILECOPY
'/u02/backup/users01.bak' LEVEL 0;
RMAN> LIST COPY; |
CATALOG DB_RECOVERY_FILE_DEST |
Catalog the Backup Pieces held in the location set by
DB_RECOVERY_FILE_DEST |
CATALOG DB_RECOVERY_FILE_DEST |
RMAN> CATALOG DB_RECOVERY_FILE_DEST; |
CATALOG DEVICE |
? |
CATALOG DEVICE ... |
TBD |
CATALOG RECOVERY |
Catalog all files in the currently enabled flash
recovery area |
CATALOG RECOVERY AREA |
RMAN> CATALOG RECOVERY AREA; |
CATALOG START |
Catalog all files in a named disk location |
CATALOG START WITH <path_name> [NOPROMPT] |
RMAN> CATALOG START 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 them, and then recatalog them in the new
location |
CHANGE ARCHIVELOG ... |
HOST 'mv $ORACLE_HOME/oradata/trgt/arch/* /fs2/arch';
CHANGE ARCHIVELOG ALL UNCATALOG;
CATALOG START WITH '/fs2/arch'; |
CHANGE BACKUP |
Change the status of all backups of server parameter files created more than a day ago to UNAVAILABLE |
CHANGE BACKUP ... |
CHANGE BACKUP OF SPFILE COMPLETED BEFORE 'SYSDATE-1' UNAVAILABLE;
CHANGE BACKUP OF ARCHIVELOG ALL
NOKEEP; |
CHANGE BACKUPSET |
Change the status a backup set |
CHANGE BACKUPSET ... |
CHANGE BACKUPSET 42 UNAVAILABLE; |
Change an ordinary backup into a long-term backup |
CHANGE BACKUPSET ... |
CHANGE BACKUP TAG
'consistent_db_bkup' KEEP FOREVER NOLOGS; |
CHANGE CHANGEFAILURE |
? |
CHANGE CHANGEFAILURE ... |
TBD |
CHANGE CONTROLFILECOPY |
? |
CHANGE CONTROLFILECOPY ... |
TBD |
CHANGE COPY |
? |
CHANGE COPY ... |
TBD |
CHANGE DATAFILECOPY |
? |
CHANGE DATAFILECOPY ... |
TBD |
CHANGE DB_UNIQUE_NAME_FROM |
? |
CHANGE DB_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. |
Configuration Defaults |
$ rman
RMAN> SHOW ALL
RMAN> CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1;
RMAN> CONFIGURE ARCHIVELOG DELETION POLICY TO NONE;
RMAN> CONFIGURE BACKUP OPTIMIZATION OFF;
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP OFF;
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F';
RMAN> CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1;
RMAN> CONFIGURE DEFAULT DEVICE TYPE TO DISK;
RMAN> CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET;
RMAN> CONFIGURE ENCRYPTION FOR DATABASE OFF;
RMAN> CONFIGURE ENCRYPTION ALGORITHM 'AES128';
RMAN> CONFIGURE MAXSETSIZE TO 2 G;
RMAN> CONFIGURE RETENTION POLICY TO REDUNDANCY 1;
RMAN> CONFIGURE SNAPSHOT CONTROLFILE NAME TO
'/app/oracle/product/flash_recovery_area/snapshot.ctl'; |
CONFIGURE AUXILIARY |
? |
CONFIGURE AUXILIARY CHANNEL <DEVICE, INTEGER> .... |
RMAN> CONFIGURE AUXILARY |
CONFIGURE AUXNAME |
Set and clear an auxiliary name for a datafile |
CONFIGURE AUXNAME FOR DATAFILE <data_file_number> TO <path_and_file_name>
CONFIGURE AUXNAME FOR DATAFILE CLEAR |
RMAN> CONFIGURE AUXNAME FOR DATAFILE
5 TO '/home/oracle/auxfiles/aux1.f';
RMAN> CONFIGURE AUXNAME FOR DATAFILE 4 CLEAR; |
CONFIGURE CHANNEL |
? |
CONFIGURE CHANNEL <DEVICE TYPE | INTEGER> <configuration | CLEAR> |
RMAN> CONFIGURE CHANNEL DEVICE
TYPE 'SBT_TAPE' CLEAR; |
? |
CONFIGURE CLONENAME .... |
RMAN> CONFIGURE CLONENAME |
CONFIGURE COMPATIBLE |
? |
CONFIGURE COMPATIBLE .... |
RMAN> CONFIGURE COMPATIBLE |
CONFIGURE COMPRESSION |
Configure a backup compression algorithm |
CONFIGURE COMPRESSION ALGORITHM <CLEAR | '<quoted_string>'> |
SELECT algorithm_name, algorithm_description
FROM v$rman_compression_algorithm;
RMAN> CONFIGURE COMPRESSION ALGORITHM 'ZLIB'; |
CONFIGURE CONTROLFILE |
Enable autobackup and configure the default autobackup
format for a DISK device |
CONFIGURE CONTROLFILE AUTOBACKUP |
CONFIGURE CONTROLFILE AUTOBACKUP
ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u02/%F'; |
CONFIGURE DB_UNIQUE_NAME |
? |
CONFIGURE DB_UNIQUE_NAME '<db_unique_name>' <CLEAR | CONNECT IDENTIFIER
'<quoted_string>'> |
TBD |
Set and clear encryption |
CONFIGURE ENCRYPTION ALGORITHM <CLEAR | encryption_algorithm> |
SQL> col algorithm_name format a20
SQL> col algorithm_description format a25
SQL> SELECT algorithm_name, algorithm_description
FROM v$rman_encryption_algorithms;
RMAN> CONFIGURE ENCRYPTION ALGORITHM
'AES256';
RMAN> CONFIGURE ENCRYPTION CLEAR; |
Configure Database or Tablespace Encryption |
CONFIGURE ENCRYPTION FOR <DATABASE | TABLESPACE <tablespace_name>>
<ON | OFF | CLEAR> |
RMAN> CONFIGURE ENCRYPTION FOR DATABASE
ON;
RMAN> CONFIGURE ENCRYPTION FOR TABLESPACE uwdata OFF; |
? |
CONFIGURE EXCLUDE ... |
TBD |
|
CONNECT |
Creates a connection between RMAN and a target, auxiliary, or recovery
catalog database |
Auxiliary |
CONNECT AUXILIARY <user_id>/<password>@<instance> |
$ rman auxiliary
oracle/oracle1@prodb |
Catalog |
CONNECT |
$ rman catalog
repoomega/oracle1@repos
$ rman
RMAN> connect catalog repoomega/oracle1@repos |
Target only |
CONNECT TARGET <user_id>/<password>@<instance> |
$ rman target /
$ rman>
RMAN> connect target / catalog
repoomega/oracle1@repos |
Target and Catalog |
CONNECT |
$ rman target /
catalog repoomega/oracle1@repos
$ rman>
RMAN> connect target / catalog
repoomega/oracle1@repos |
Target without a catalog |
CONNECT |
$ rman
RMAN> connect target omega1/omega1@emrep NOCATALOG |
|
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 |
CONVERT DATABASE NEW DATABASE '<db_name>'
TRANSPORT SCRIPT '<script_location>'
TO PLATFORM '<platform_name>'
DB_FILE_NAME_CONVERT '<source_location> <destination_location>' |
CONVERT DATABASE
NEW DATABASE 'prodb'
TRANSPORT SCRIPT '/tmp/convertdb/transportscript'
TO PLATFORM 'Linux IA (64-bit)'
DB_FILE_NAME_CONVERT '/u01/oradata', '/stage/dbfiles'; |
CONVERT DATAFILE |
Converts the datafiles to be transported to the destination host format and deposits the results in
/u02/oradata |
CONVERT DATAFILE <datafile_name_list>
DB_FILE_NAME_CONVERT '<source_location> <destination_location>'
FROM PLATFORM <original_platform_name> |
CONVERT DATAFILE
'/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/oradata'
FROM PLATFORM 'Linux IA (64-bit)'; |
CONVERT TABLESPACE |
Convert a tablespaces to 64 bit Linux |
CONVERT TABLESPACE <tablespace_name_list> TO PLATFORM <platform_name> FORMAT
'<format_string>' |
desc v$transportable_platform
SELECT platform_name, endian_format
FROM v$transportable_platform;
CONVERT TABLESPACE uwdata, users TO PLATFORM 'Linux IA (64-bit)'
FORMAT '/app/oracle/product/flash_recovery_area/linux64/%U'; |
|
COPY |
? |
COPY ARCHIVELOG ... (level, nochecksum, nokeep, reuse, tag) |
RMAN> COPY ARCHIVELOG |
? |
COPY BACKUP ... |
RMAN> COPY BACKUP |
? |
COPY CHECK ... |
RMAN> COPY CHECK |
? |
COPY CONTROLFILECOPY ... |
RMAN> COPY CONTROLFILECOPY |
? |
COPY CURRENT ... |
RMAN> COPY CURRENT |
? |
COPY DATAFILE ... |
RMAN> COPY DATAFILE |
? |
COPY DATAFILECOPY ... |
RMAN> COPY DATAFILECOPY |
? |
COPY KEEP ... |
RMAN> COPY KEEP |
|
CREATE |
CREATE CATALOG |
Create a recovery catalog or a virtual private catalog |
CREATE [VIRTUAL] CATALOG; |
RMAN> CREATE CATALOG;
SQL> conn repoomega/oracle1@repos
SQL> SELECT object_type, COUNT(*)
FROM user_objects;
RMAN> DROP CATALOG;
SQL> SELECT object_type, COUNT(*)
FROM user_objects; |
CREATE RESTORE POINT |
Create a restore point |
CREATE RESTORE POINT <restore_point_name> |
RMAN> CREATE RESTORE POINT
app_patch;
RMAN> DROP RESTORE POINT app_patch; |
CREATE SCRIPT |
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}
FROM FILE '<file_name>' |
CREATE SCRIPT backup_whole
COMMENT "backup whole database and logs"
{
BACKUP INCREMENTAL LEVEL 0 TAG b_whole_l0
DATABASE PLUS ARCHIVELOG;
} |
Creates a stored script called backup_whole that backs up the database
and archived redo logs |
CREATE GLOBAL SCRIPT global_backup_db
COMMENT "backup any database from the recovery catalog, with logs"
{
BACKUP DATABASE PLUS ARCHIVELOG;
} |
|
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 |
Description |
AVAILABLE |
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. |
The following objects can be crosschecked:
ARCHIVELOG |
BACKUP |
BACKUPPIECE |
BACKUPSET |
CONTROLFILECOPY |
COPY |
DATAFILECOPY |
PROXY |
|
CROSSCHECK ARCHIVELOG |
Allocate a channel and crosscheck all archivelogs |
CROSSCHECK <archivelogRecordSpecifier> |
RMAN> RUN
{
ALLOCATE CHANNEL d1 FOR
MAINTENANCE DEVICE TYPE DISK;
CROSSCHECK ARCHIVELOG ALL;
RELEASE CHANNEL;
} |
CROSSCHECK BACKUP |
Allocate a channel, crosscheck backups in a date range and release the channel after use |
CROSSCHECK BACKUP .... |
RMAN> RUN
{
ALLOCATE CHANNEL d1 FOR
MAINTENANCE DEVICE TYPE DISK;
CROSSCHECK BACKUP DEVICE TYPE DISK COMPLETED BETWEEN '01-JUL-08' AND
'30-SEP-08';
RELEASE CHANNEL;
} |
CROSSCHECK BACKUPPIECE |
Checks that specific backuppieces still exist |
CROSSCHECK BACKUPPIECE .... |
RMAN> CROSSCHECK BACKUPPIECE |
CROSSCHECK BACKUPSET |
Checks that specific
backupsets still exist |
CROSSCHECK BACKUPSET OF <backupset
identifier>; |
RMAN> CROSSCHECK BACKUPSET OF
TABLESPACE UWDATA; |
CROSSCHECK COPY |
Checks for the
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. |
CROSSCHECK COPY ... |
RMAN> CROSSCHECK COPY OF ARCHIVELOG ALL; |
CROSSCHECK CONTROLFILECOPY |
Checks that specific
controlfile copies still exist |
CROSSCHECK CONTROLFILECOPY .... |
RMAN> CROSSCHECK CONTROLFILECOPY |
CROSSCHECK DATAFILECOPY |
Checks that specific
bdatafile copies still exist |
CROSSCHECK DATAFILECOPY <ALL | INTEGER | LIKE | QUOTED_STRING> |
RMAN> CROSSCHECK DATAFILECOPY ALL; |
CROSSCHECK FOREIGN |
Crosscheck all
foreign archived redo logs |
CROSSCHECK FOREIGN ARCHIVELOG <ALL | FROM | HIGH | LOGSEQ | LOW | SCN |
SEQUENCE | TIME | UNTIL> .... |
RMAN> CROSSCHECK FOREIGN ARCHIVELOG ALL; |
CROSSCHECK PROXY |
Crosscheck the
existence of a specific proxy copy |
CROSSCHECK PROXY |
*RMAN> CROSSCHECK PROXY 941; |
|
DEBUG |
Commands for the RMAN debugger |
DEBUG <AFFINITY | ALL | DUPLICATE | IO | KRB | MISC | NODEVALS | OFF | ON |
PACKAGES | PLSQL | RCVCAT | RCVMAN | RECOVER | RESTORE | RESYNC | RPC | SQL> |
*RMAN> DEBUG ALL;
*RMAN> DEBUG OFF; |
|
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 |
DELETE ARCHIVELOG <ALL | FROM | HIGH | LIKE | LOGSEQ | LOW | QUOTED_STRING |
SCN | SEQUENCE | TIME | UNTIL> .... |
RMAN> LIST ARCHIVELOG LIKE
'%';
RMAN> CROSSCHECK ARCHIVELOG LIKE '%';
RMAN> DELETE ARCHIVELOG LIKE '%'; |
DELETE BACKUPSET |
Delete Backup Set |
? |
*DELETE NOPROMPT BACKUP OF DATABASE COMPLETED BEFORE 'SYSDATE-7'; |
Delete both Disk and Tape Backup Sets |
? |
# back up datafile to disk and tape
BACKUP DEVICE TYPE DISK DATAFILE 1 TAG "weekly_bkup";
BACKUP DEVICE TYPE sbt DATAFILE 1 TAG "weekly_bkup";
# manually allocate disk and sbt channels
ALLOCATE CHANNEL FOR MAINTENANCE DEVICE TYPE DISK;
ALLOCATE CHANNEL FOR MAINTENANCE DEVICE TYPE SBT;
DELETE BACKUPSET TAG "weekly_bkup"; |
DELETE EXPIRED |
Deletes expired backup records |
DELETE [FORCE | NOPROMPT] EXPIRED
<maintenance_spec> [for db_unique_name_option]; |
RMAN> CROSSCHECK
BACKUP;
RMAN> DELETE
EXPIRED BACKUP;
RMAN> CROSSCHECK BACKUPSET OF TABLESPACE uwdata DEVICE TYPE disk COMPLETED
BEFORE SYSDATE-15;
RMAN> DELETE
NOPROMPT EXPIRED BACKUPSET OF TABLESPACE
uwdata DEVICE TYPE disk COMPLETED BEFORE SYSDATE-15; |
DELETE OBSOLETE |
Delete Obsolete |
DELETE [FORCE | NOPROMPT] OBSOLETE
[obsOperandList] [device_type] [device_specifier]; |
RMAN> DELETE FORCE
OBSOLETE; |
DELETE SCRIPT |
Deletes a stored script b_whole_10 from the recovery catalog |
DELETE [GLOBAL] SCRIPT '<script_name>' |
rman TARGET / CATALOG rman/cat@catdb
RMAN> DELETE SCRIPT b_whole_10;
RMAN> DELETE GLOBAL SCRIPT b_whole_10; |
|
Drop |
DROP CATALOG |
Drop the RMAN catalog |
DROP CATALOG; |
*See CREATE CATALOG Demo Above |
DROP DATABASE |
Use RMAN to issue the drop database command |
DROP DATABASE; |
No demo is shown as this is something I would strongly
recommend against doing within RMAN. |
DROP RESTORE POINT |
Drop a restore point |
DROP RESTORE POINT <restore_point_name> |
*See CREATE RESTORE POINT Demo Above |
|
DUPLICATE |
Allocates axiliary channels and duplicates the target database as newdb |
DUPLICATE [TARGET] DATABASE TO <new_name>
LOGFILE '<redo_log_file_path_and_name>' SIZE <integer> <K | M>
[SKIP READONLY] [NOFILENAMECHECK] |
RUN {
ALLOCATE AUXILIARY CHANNEL d1 DEVICE TYPE DISK;
ALLOCATE AUXILIARY CHANNEL d2 DEVICE TYPE DISK;
DUPLICATE TARGET DATABASE TO newdb
LOGFILE
'?/oradata/aux1/redo01.log' SIZE 50M,
'?/oradata/aux1/redo02.log' SIZE 50M,
'?/oradata/aux1/redo03.log' SIZE 50M
SKIP READONLY
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 |
FLASHBACK DATABASE TO SCN=<integer> |
*RMAN> FLASHBACK DATABASE TO SCN=42678315; |
|
GRANT |
Grant privileges to a recovery catalog user |
GRANT <privilege> TO <schema_name> |
*RMAN> GRANT CATALOG FOR DATABASE
orabase TO repoomega;
*RMAN> GRANT REGISTER DATABASE TO repoomega; |
|
HOST |
Shell out of RMAN to the operating system for command execution |
HOST |
*See EXIT Demo Above |
|
IMPORT |
IMPORT CATALOG |
Imports the metadata from one recovery catalog into a different recovery
catalog |
? |
? |
IMPORT RCVCAT |
? |
? |
? |
|
LIST |
Produce a detailed listing of the indicated items |
LIST <ARCHIVELOG | COPY | DB_UNIQUE_NAME | FAILURE> ALL; |
*RMAN> LIST ARCHIVELOG ALL;
*RMAN> LIST COPY;
*RMAN> LIST DB_UNIQUE_NAME ALL;
*For LIST FAILURE See Advise Failure Demo Above |
List the most recent Level 0 backups |
Lisa T. was kind enough to send in this useful bit of code that will give you a list of the most recent Level 0 backups. |
select distinct to_char((b.CHECKPOINT_TIME), 'YYYY-MM-DD HH:MI.SS') t
from v$backup_datafile b, v$tablespace ts, v$datafile f
where b.incremental_level = 0
and INCLUDED_IN_DATABASE_BACKUP='YES'
and f.file#=b.file#
and f.ts#=ts.ts#
group by b.checkpoint_time
order by 1;
|
|
PRINT SCRIPT |
Display a stored script |
PRINT <IDENTIFIER | QUOTED_STRING> |
See CREATE SCRIPT Demos Above |
|
PURGE |
? |
PURGE |
See "CREATE SCRIPT" Demos Above |
|
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 |
REGISTER DATABASE |
*RMAN> REGISTER DATABASE; |
|
RELEASE CHANNEL |
Release a channel that was allocated with an ALLOCATE CHANNEL command or
ALLOCATE CHANNEL FOR MAINTENANCE command |
RELEASE CHANNEL |
See ? Demo Above |
|
REPAIR FAILURE |
Repair one or more failures recorded in the automated diagnostic
repository |
REPAIR FAILURE [<NO | NOPROMPT | PREVIEW | USING> |
*See Advise Failure Demo Above |
|
REPLACE SCRIPT |
Replace an existing script stored in the recovery catalog. If the script
does not exist, then REPLACE SCRIPT creates it |
REPLACE SCRIPT |
TBD |
|
REPORT |
Perform detailed analyses on recovery catalog metadata |
REPORT |
RMAN> REPORT SCHEMA; |
|
RESET DATABASE |
Reset the incarnation of the target database in the RMAN repository to a
previous database incarnation |
RESET DATABASE TO INCARNATION
<incarnation_identifier>; |
$ rman target /
nocatalog
RMAN> STARTUP NOMOUNT;
RMAN> RESTORE CONTROLFILE FROM AUTOBACKUP;
RMAN> ALTER DATABASE MOUNT;
RMAN> LIST INCARNATION OF DATABASE orabase;
RMAN> RESET DATABASE TO INCARNATION 1;
RMAN> RESTORE DATABASE UNTIL SCN 4208974;
RMAN> RECOVER DATABASE UNTIL SCN 4208974;
RMAN> ALTER DATABASE OPEN RESETLOGS;
RMAN> LIST INCARNATION OF DATABASE orabase; |
|
RESTORE |
Restore files from backup sets or from disk copies to the default or a new location |
RESTORE |
RMAN> target / catalog rman/rman@rman
RMAN> backup database;
RMAN> validate backupset 1;
SQL> conn scott/tiger
SQL> DELETE FROM emp WHERE rownum < 6;
SQL> COMMIT;
RMAN> restore database; |
|
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 |
RESYNC CATALOG FROM CONTROLFILECOPY '<file_name>'
RESYNC FROM DB_UNIQUE_NAME ALL
RESYNC FROM DB_UNIQUE_NAME '<db_unique_name>' |
Mount the target database, update the repository in the current control
file with metadata from a backup control file, then open the database |
$ rman target /
RMAN> STARTUP FORCE MOUNT;
RMAN>
RESYNC CATALOG FROM CONTROLFILECOPY '/u01/cfile.dbf';
RMAN>
ALTER DATABASE OPEN; |
After adding a datafile to an existing tablespace |
*RMAN> RESYNC CATALOG; |
|
Revoke |
Revoke privileges from a recovery catalog user |
REVOKE |
TBD |
|
Run |
Execute a script of RMAN commands |
RUN {
<script commands>
} |
See "Allocate A Single Backup Channel" Demo Above |
|
Send |
Send a vendor-specific quoted string to one or more specific channels |
SEND CHANNEL |
Specify commands by CHANNEL |
SEND CHANNEL '<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 |
SEND DEVICE_TYPE '<device_specifier>' '<command_string>'
PARMS '<channel_params>' |
RUN
{
ALLOCATE CHANNEL c1 DEVICE TYPE sbt;
SEND 'OB_DEVICE stape1';
BACKUP TABLESPACE users;
} |
|
Set |
Set the value of various attributes that affect RMAN behavior for the
duration of a RUN block or a session |
? |
SET <OFF | ON> [FOR ALL TABLESPACES] |
TBD |
Restore database and recover until the specified date and time |
SET ARCHIVELOG DESTINATION TO '<
SET BACKUP COPIES <integer>
SET COMPRESSION ALGORITHM '<compression_algorithm_name>'
SET DECRYPTION IDENTIFIED BY <password>
SET ECHO <ON | OFF>
SET ENCRYPTION ALGORITHM '<algorithm_name>'
SET IDENTIFIED BY <password> [ONLY]
SET MAXCORRUPT FOR DATAFILE <dataFileSpec> TO <integer>
SET NEWNAME FOR DATAFILE <dataFileSpec> TO '<file_name>'
SET NEWNAME FOR DATAFILE <dataFileSpec> TO NEW
SET NEWNAME FOR TEMPFILE <tempFileSpec> TO '<quoted_string>'
SET NEWNAME FOR TEMPFILE <tempFileSpec> TO NEW
SET TO RESTORE POINT <restore_point_name>
SET UNTIL <TIME | SCN> |
CONFIGURE ARCHIVELOG COPIES FOR DEVICE TYPE sbt TO 3;
CONFIGURE DATAFILE COPIES FOR DEVICE TYPE sbt TO 3;
RMAN> run {
ALLOCATE CHANNEL dev1 DEVICE TYPE sbt
PARMS 'ENV=(OB_DEVICE_1=stape1,OB_DEVICE_2=stape2)';
* SET BACKUP COPIES 2;
BACKUP DATABASE PLUS ARCHIVELOG;
} |
RMAN> run {
SET UNTIL TIME = "TO_DATE('03/15/08 10:42:07','MM/DD/RR HH24:MI:SS')";
RESTORE DATABASE;
RECOVER DATABASE;
} |
? |
SET AUXILIARY INSTANCE PARAMETER FILE TO '<file_name>
SET COMMAND ID TO '<string>'
SET CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE <deviceSpecifier> TO <formatSpec>
SET DBID <integer> |
RMAN> RUN {
ALLOCATE CHANNEL d1 DEVICE TYPE DISK FORMAT '/u01/%U';
ALLOCATE CHANNEL d2 DEVICE TYPE DISK FORMAT '/u02/%U';
SET COMMAND ID TO 'rman';
BACKUP INCREMENTAL LEVEL 0 DATABASE;
SQL 'ALTER SYSTEM ARCHIVE LOG CURRENT';
} |
RMAN> SET DBID 3257174182;
RMAN> STARTUP FORCE NOMOUNT;
RMAN> RUN {
ALLOCATE CHANNEL t1 DEVICE TYPE sbt;
RESTORE SPFILE FROM AUTOBACKUP;
}
STARTUP FORCE; # RMAN restarts database with restored SPFILE |
$ rman target /
RMAN> STARTUP FORCE NOMOUNT
RMAN> SET DBID 28014364;
RMAN> RUN {
SET CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u02/cf_%F.bak';
RESTORE CONTROLFILE FROM AUTOBACKUP MAXSEQ 100;
}
ALTER DATABASE MOUNT;
RECOVER DATABASE;
ALTER DATABASE OPEN RESETLOGS; |
|
Show |
All |
ALL |
$ rman target / catalog repoomega1/oracle1@repos
RMAN> show all; |
Auxname |
AUXNAME |
$ rman target / catalog repoomega1/oracle1@repos
RMAN> show auxname; |
Backup Copies |
{DATAFILE | ARCHIVELOG} BACKUP COPIES |
$ rman target / catalog repoomega1/oracle1@repos
RMAN> show datafile backup copies;
RMAN> show archivelog backup copies; |
Backup Optimization |
BACKUP OPTIMIZATION |
$ rman target / catalog repoomega1/oracle1@repos
RMAN> show backup optimization; |
Channel |
[AUXILIARY] CHANNEL [FOR DEVICE TYPE <deviceSpecifier>] |
$ rman target / catalog repoomega1/oracle1@repos
RMAN> show channel; |
Control File Auto-Backup |
CONTROLFILE AUTOBACKUP [FORMAT] |
$ rman target / catalog repoomega1/oracle1@repos
RMAN> show controfile autobackup; |
Control File Auto-Backup Format |
CONTROLFILE AUTOBACKUP FORMAT <format mask> |
$ rman target / catalog repoomega1/oracle1@repos
RMAN> show controfile autobackup; |
Database Encryption |
ENCRYPTION FOR DATABASE |
$ rman target / catalog repoomega1/oracle1@repos
RMAN> show encryption for database; |
Device Type |
[DEFAULT] DEVICE TYPE |
$ rman target / catalog repoomega1/oracle1@repos
RMAN> show device type; |
Encryption Algorithm |
ENCRYPTION ALGORITHM |
$ rman target / catalog repoomega1/oracle1@repos
RMAN> show encryption algorithm; |
Exclude |
EXCLUDE |
$ rman target / catalog repoomega1/oracle1@repos
RMAN> show exclude; |
Maximum Backup Set Size |
MAXSETSIZE |
$ rman target / catalog repoomega1/oracle1@repos
RMAN> show maxsetsize; |
Retention Policy |
RETENTION POLICY |
$ rman target / catalog repoomega1/oracle1@repos
RMAN> show retention policy;
RMAN> show retention policy to redundancy; |
Snapshot Control File Name |
SNAPSHOT CONTROLFILE NAME |
$ rman target / catalog repoomega1/oracle1@repos
RMAN> SHOW SNAPSHOT CONTROLFILE NAME; |
|
Shutdown |
Shutdown the target database |
SHUTDOWN <ABORT | IMMEDIATE | NORMAL | TRANSACTIONAL> |
RMAN> SHUTDOWN ABORT; |
|
Spool |
Write RMAN output to a log file |
SPOOL LOG OFF
SPOOL LOG TO <file_name> [APPEND] |
CONFIGURE DEFAULT DEVICE TYPE TO sbt;
SPOOL LOG TO '/tmp/current_config.log';
SHOW ALL;
SPOOL LOG OFF;
SPOOL LOG TO '/home/oracle/rman.log';
BACKUP DATABASE;
SPOOL LOG OFF; |
|
SQL |
Execute a SQL statement from within RMAN |
SQL '<SQL_statement>' |
RUN
{
SQL 'ALTER SYSTEM ARCHIVE LOG CURRENT';
} |
|
Startup |
Startup a Database |
STARTUP <DBA | FORCE | MOUNT | NOMOUNT>
STARTUP PFILE '<file_name>' |
$ rman TARGET / CATALOG repoomega/oracle1@repos
RMAN> STARTUP MOUNT; |
|
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 to point to an ImageCopy of the data file |
SWITCH DATABASE TO COPY |
TBD |
|
SWITCH DATAFILE '<data_file_specification>' TO COPY |
TBD |
|
SWITCH DATAFILE '<data_file_specification>' TO DATAFILECOPY '<file_name>' |
TBD |
|
SWITCH DATAFILE '<data_file_specification>' TO DATAFILECOPY TAG '<tag_name>' |
TBD |
A disk fails, forcing a datafile restore to a new disk
location. Connecting to the TARGET, SET NEWNAME to rename the datafile, then RESTORE the missing datafile.
Run SWITCH to point the control file to the new datafile and then RECOVER. |
SWITCH DATAFILE ALL |
RUN {
ALLOCATE CHANNEL d1 DEVICE TYPE DISK;
SQL "ALTER TABLESPACE uwdata OFFLINE IMMEDIATE";
SET NEWNAME FOR DATAFILE '/u01/oradata/users01.dbf' TO '/u02/oradata/users01.dbf';
RESTORE TABLESPACE uwclass;
SWITCH DATAFILE ALL;
RECOVER TABLESPACE uwclass;
SQL "ALTER TABLESPACE uwclass ONLINE";
} |
Assume all datafiles of the USERS tablespace are
damaged but image copies exist in the FRA. Connect to the TARGET and use SWITCH to point the control file to the
new datafiles then RECOVER. |
SWITCH TABLESPACE '<tablespace_name>' TO COPY |
SQL "ALTER TABLESPACE users OFFLINE IMMEDIATE";
SWITCH TABLESPACE users TO COPY;
RECOVER TABLESPACE users;
SQL "ALTER TABLESPACE users ONLINE"; |
|
SWITCH TEMPFILE <temp_file_specification> TO '<file_name>' |
TBD |
|
SWITCH TEMPFILE ALL |
TBD |
|
Transport Tablespace |
Create transportable tablespace sets from backup for one or more
tablespaces |
TRANSPORT TABLESPACE |
TBD |
|
Unregister |
Unregister a Database from the
Catalog |
UNREGISTER DATABASE '<database_name>' [NOPROMPT] |
RMAN> UNREGISTER DATABASE; |
UNREGISTER DB_UNIQUE_NAME '<db_unique_name>' [INCLUDING BACKUPS [NOPROMPT]] |
RMAN> LIST DB_UNIQUE_NAME ALL;
RMAN> UNREGISTER DB_UNIQUE_NAME 'ORADATA'; |
|
Upgrade Catalog |
Upgrade the recovery catalog schema from an older version to the version
required by RMAN |
UPGRADE CATALOG |
RMAN> UPGRADE CATALOG; |
|
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 |
VALIDATE ARCHIVELOG ALL
VALIDATE ARCHIVELOG LIKE '<string_pattern>'
VALIDATE ARCHIVELOG FROM SCN <integer>
VALIDATE ARCHIVELOG BETWEEN SCN <integer> AND SCN <integer>
VALIDATE ARCHIVELOG UNTIL SCN <integer>
VALIDATE ARCHIVELOG FROM SEQUENCE <integer> [THREAD <integer>]
VALIDATE ARCHIVELOG SEQUENCE <integer> [THREAD <integer>]
VALIDATE ARCHIVELOG SEQUENCE BETWEEN <integer> AND <integer>
VALIDATE ARCHIVELOG UNTIL SEQUENCE <integer> [THREAD <integer>]
TIME BETWEEN '<date_string>' AND '<date_string>'
UNTIL TIME '<date_string>' |
RMAN> VALIDATE ARCHIVELOG ALL; |
? |
VALIDATE BACKUPSET <primaryKey> |
TBD |
Validate all control files copies |
VALIDATE CONTROLFILECOPY ALL
VALIDATE CONTROLFILECOPY '<file_name>'
VALIDATE CONTROLFILECOPY LIKE '<string_pattern>' |
RMAN> VALIDATE CONTROLFILECOPY ALL; |
Validate all database, datafile, or tablespace copies |
VALIDATE COPY OF DATABASE
VALIDATE COPY OF DATAFILE '<file_name>'
VALIDATE COPY OF DATAFILE <file_number>
VALIDATE COPY OF TABLESPACE '<tablespace_name>' |
RMAN> VALIDATE COPY OF TABLESPACE 'UWDATA'; |
? |
VALIDATE <blockObject> |
TBD |
Validate the current control file |
VALIDATE CURRENT CONTROLFILE |
RMAN> VALIDATE CURRENT CONTROLFILE; |
Validate the complete database |
VALIDATE DATABASE |
RMAN> VALIDATE DATABASE; |
Validate the identified datafile |
VALIDATE DATAFILE '<file_name>'
VALIDATE DATAFILE <file_number> |
RMAN> VALIDATE DATAFILE
'C:\ORACLE\PRODUCT\ORADATA\ORABASE\UWDATA01';
RMAN> VALIDATE DATAFILE
9; |
Validate the recovery file destination |
VALIDATE DB_RECOVERY_FILE_DEST |
RMAN> VALIDATE DB_RECOVERY_FILE_DEST; |
Validate the recovery area |
VALIDATE RECOVERY AREA |
RMAN> VALIDATE RECOVERY AREA; |
Validate recovery the files |
VALIDATE RECOVERY FILES |
RMAN> VALIDATE RECOVERY FILES; |
Validate the server parameter file |
VALIDATE SPFILE |
RMAN> VALIDATE SPFILE; |
Validate the named tablespace |
VALIDATE TABLESPACE <tablespace_name_list> |
RMAN> VALIDATE TABLESPACE
uwdata; |
|
RMAN Demos |
Using a target database controlfile instead of recovery catalog
The following were provided to PSOUG by member Andrea Sparling |
RMAN> CONFIGURE RETENTION POLICY TO REDUNDANCY 1;
RMAN> CONFIGURE BACKUP OPTIMIZATION OFF; # default
RMAN> CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK
TO '%F';
RMAN> CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO
COMPRESSED
BACKUPSET; # default
RMAN> CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1;
RMAN> CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1;
RMAN> CONFIGURE MAXSETSIZE TO 2 G;
RMAN> CONFIGURE ARCHIVELOG DELETION POLICY TO NONE;
RMAN> CONFIGURE SNAPSHOT CONTROLFILE NAME TO
'/u01/app/oracle/product/10.1.0.3/dbs/snapcf_pnbdb.f'; |
Incremental Level 0 Backup |
RMAN> connect target /
RMAN> BACKUP INCREMENTAL LEVEL 0
TAG full_backup
FORMAT '/u03/backup/rman_fullbackup_%d_%t.%s.%c.%p.bus'
DATABASE;
RMAN> COPY CURRENT CONTROLFILE TO '/u03/backup/ctrlfile.backup';
RMAN> CROSSCHECK BACKUP;
RMAN> CROSSCHECK ARCHIVELOG ALL;
RMAN> DELETE OBSOLETE;
RMAN> DELETE EXPIRED ARCHIVELOG ALL;
RMAN> LIST BACKUP;
RMAN> LIST ARCHIVELOG ALL; |
Incremental |
#!/bin/sh
#####################################################
# script to take a rman full backup
# this script must be run
# as the trusted user '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
export
ORACLE_BASE=/u01/app/oracle;
export ORACLE_HOME=$ORACLE_BASE/product/10.1.0.3;
export ORACLE_SID=pnbdb;
export LD_LIBRARY_PATH=/u01/app/oracle/product/10.1.0.3/lib:/lib:/usr/lib;
# set relative head of directory (work disk is u03, oracle disk is u01)
HEAD=/u03
WORK=$HEAD/backup/scripts
cd $WORK
# unique logfile
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
echo instance $ORACLE_SID >> $LOGFILE
##########################################################################
${ORACLE_HOME}/bin/rman @${WORK}/rman_full.rcv >> $LOGFILE
returncode=$?
echo $returncode return code >> $LOGFILE
df >> $LOGFILE
echo "Ended " >> $LOGFILE
date >> $LOGFILE
if [ $returncode -ne 0 ]; then
echo " email error log " >> $LOGFILE
mail [email protected] -s"RMAN ERROR LOG for parnassus pnbdb backup"
< $LOGFILE
mail [email protected] -s"RMAN ERROR LOG for parnassus pnbdb backup" <
$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 |
ALLOCATE CHANNEL FOR MAINTENANCE DEVICE TYPE DISK CONNECT 'sys/oracle1@inst1';
ALLOCATE CHANNEL FOR MAINTENANCE DEVICE TYPE DISK CONNECT 'sys/oracle1@inst2';
CROSSCHECK BACKUP; |
|
RMAN
Related Queries |
? |
SELECT recovery_estimated_ios, actual_redo_blks, target_redo_blks, target_mttr, estimated_mttr
FROM gv$instance_recovery;
SELECT * FROM v_$recovery_file_dest;
SELECT COUNT(*) FROM dba_hist_instance_recovery;
cd /app/oracle/product/OracleHomes/oradata/orcl
ls -la
cd /app/oracle/product/OracleHomes/admin/orcl/bdump
tail alert_orcl.log
rm control02.ctl
ls -la
SQL> conn hr/hr (after unlocking account)
SQL> desc jobs
SQL> INSERT INTO jobs VALUES (987,'TEST',0,1);
SQL> COMMIT;
-- also build a dummy table
tail alert_orcl.log
-- no one knows anything bad has happened
SQL> select file_name from mgmt$db_controlfiles;
-- lets do a shutdown and restart
SQL> shutdown immediate;
SQL> conn / as sysdba
Connected.
SQL> shutdown immediate;
ORA-00210: cannot open the specified control file
ORA-00202: control file:
'/app/oracle/product/OracleHomes/oradata/orcl/control02.ctl'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3
-- now we have a problem
SQL> shutdown abort;
tail the alert log and we know what happened
RUN
{
STARTUP FORCE NOMOUNT;
RESTORE CONTROLFILE;
DATABASE MOUNT;
RESTORE DATABASE;
RECOVER DATABASE;
}
alter database open resetlogs;
ls -la shows control files back
rman done
-- hadn't done a backup after last restore
RMAN> run {startup force nomount; restore controlfile;
alter database mount;}
tail the alert log
--
look at /app/oracle/OracleHomes/oradata/orcl
-- the file is restored
ls -la
conn / as sysdba
shutdown immediate;
startup
-- note error message
SQL> startup
ORACLE instance started.
Total System Global Area 440401920 bytes
Fixed Size 1219880 bytes
Variable Size 130024152 bytes
Database Buffers 306184192 bytes
Redo Buffers 2973696 bytes
Database mounted.
ORA-01589: must use RESETLOGS or NORESETLOGS option
for database open
SQL> startup mount;
tail alert_orcl.log
-- next dumped controlfiles 1 and 3
shutdown immediate fails
shutdown abort
connect to RMAN |
|
Backup and
Recovery Practices Best Practices |
Metalink Note:
388422.1 |
1. Turn on block
checking
REASON: The aim is to detect, very early the presence of corrupt blocks in the database.
This has a slight performance overhead, but Checksums allow Oracle to detect early
corruption caused by underlying disk, storage system, or I/O system problems.
SQL> alter system set db_block_checking = true scope=both;
2. Turn on block tracking when using RMAN backups (if running 10g or
above)
REASON: This will allow RMAN to backup only those blocks that have changed since the last full
backup, which will reduce the time taken to back up, as less blocks will be backed up.
SQL> alter database enable block change tracking using file
�/u01/oradata/ora1/change_tracking.f�;
3. Duplex log groups and members and have more than one archive log
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> alter system set log_archive_dest_2='location=/new/location/archive2' scope=both;
SQL> alter database add logfile member '/new/location/redo21.log' to group 1;
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> backup check logical database plus archivelog delete input;
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> restore validate database;
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> backup database filesperset 1 plus archivelog delete input;
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> alter system set control_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> delete obsolete;
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> crosscheck backup;
RMAN> delete expired backup;
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> configure controlfile autobackup on;
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> recover database test;
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. |