Oracle® Database Backup and Recovery Reference 10g Release 2 (10.2) Part Number B14194-02 |
|
|
View PDF |
Syntax
backup::=
backupSpec::=
copyOfSpec::=
duration::=
sizeSpec::=
skipSpec::=
Purpose
To back up a database, tablespace, datafile (current or copy), control file (current or copy), SPFILE, archived log, or backup set.
Note: RMAN can only back up datafiles, controlfiles, SPFILEs, archived redo log files, as well as backups of these files created by RMAN.Although the database depends on other types of files for operation, such as network configuration files, password files, and the contents of the Oracle home, these files cannot be backed up with RMAN. Likewise, some features of Oracle, such as external tables or the BFILE datatype, store data in files other than those listed above. RMAN cannot back up those files. You must use some non-RMAN backup solution for any files not in the preceding list. |
RMAN can back up a target or standby database. The term backup refers to the files created by an RMAN BACKUP
command.
Backup Sets, Backup Pieces, Image Copies, and Proxy Copies
When the AS
BACKUPSET
option is used, RMAN generates one or more backup sets, which are RMAN-specific logical structures. The backup set is the smallest unit of a backup. By default, each backup set contains 4 or fewer datafiles or 16 or fewer archived logs.
Note: RMAN only records complete backup sets in the RMAN repository. There are no partial backup sets. When a BACKUP command creates backup pieces but does not produce a complete backup set for any reason, the backup pieces are discarded. |
Each backup set contains at least one backup piece, which is an RMAN-specific physical file containing the backed up data. You can also use the BACKUP
command to generate a proxy copy, which is a backup to a third-party medium in which the entire data transfer is conducted by a media manager.
Backup sets can be created on disk, or on media manager devices such as tape drives.
When the AS
COPY
option is used, RMAN generates image copies of the input files. An image copy is a byte-for-byte identical copy of the original file. You can create image copy backups of datafiles, datafile copies, and archived redo log files. Image copy files can only exist on disk.
You can create and restore image copy backups with RMAN, or with a native operating system command for copying files. However, when you use RMAN to create image copies, they are recorded in the RMAN repository, and are more easily available for use in restore and recovery operations. Otherwise, you must use the CATALOG command to add the image copies to the RMAN repository before RMAN can use them.
By default, RMAN creates all backups as backup sets, on tape or on disk. You can change the default backup type for disk backups to be image copies using the CONFIGURE command. Backups to tape can only be backup sets.
Incremental Backups
Incremental backups copy only those blocks that have changed since a previous backup. A level 0 incremental backup captures all data blocks in a datafile. Level 1 incremental backups capture changes since a previous backup. Level 1 backups can be cumulative, in which case they capture changes since the last level 0 incremental backup, or differential, in which case they capture changes since the last level 0 or level 1 incremental backup.
Block Change Tracking for Incremental Backups
You can improve incremental backup performance by enabling block change tracking, in which case RMAN keeps a record of which blocks have changed, and uses this record whenever possible to avoid scanning entire datafiles.
For details on block change tracking, including how to enable and disable it, see Oracle Database Backup and Recovery Basics.
Incrementally Updated Backups: Rolling Forward Datafile Image Copies
By using the BACKUP INCREMENTAL
... FOR RECOVER OF COPY WITH TAG
... syntax you can create level 1 incremental backups suitable for rolling forward a level 0 incremetal image copy backup of your database. RECOVER COPY OF... WITH TAG...
is used to perform incremental update of a backup.
Note: This technique is used in Enterprise Manager's Oracle-suggested Strategy for backups to disk. |
For more details on incrementally updated backups, see Oracle Database Backup and Recovery Basics.
Incremental Roll Forward of Database Copy: Updating Standby Databases
RMAN's Incremental Roll Forward of Database Copy feature enables you to synchronize a standby database with a source database by creating an incremental backup at the source database containing all changed blocks since the standby was created or last synchronized, and then applying that incremental backup at the standby.
The incremental backup is created at the source database using the BACKUP
INCREMENTAL
FROM
SCN
=
n
form of the BACKUP
command. All blocks changed at SCNs greater than or equal to the specified SCN are included in the incremental created by this BACKUP
command.
Note: The resulting backup is not considered to be part of any backup strategy at the source database. It is not suitable for use in a normalRECOVER DATABASE operation at the source database. |
At the standby database, the RECOVER
command is used with the NOREDO
option to apply the incremental backup to the standby. All changed blocks captured in the incremental backup are updated at the standby, bringing it up to date with the original.
Encryption of Backup Sets
RMAN can transparently encrypt data written to backup sets and decrypt those backup sets when they are needed in a RESTORE
operation, based upon several different encryption algorithms (listed in V$RMAN_ENCRYPTION_ALGORITHMS
). RMAN offers three modes of encryption:
Transparent encryption, in which RMAN can create and restore encrypted backups with no special DBA intervention, as long as the required Oracle key management infrastructure is available
Password-based encryption, where a password is specified during the backup, and the same password must be supplied to restore the backup.
Dual-mode encryption, where backups can be created using either as with transparent encryption or password-based encryption, and where decryption can be performed based upon either the Oracle Encryption Wallet, or a password the DBA supplies at decryption time.
For an overview of the encrypted backups mechanism, a guide to its use and information on choosing among the different modes of encryption, see Oracle Database Backup and Recovery Advanced User's Guide. The RMAN CONFIGURE, SET and SHOW commands are used to manage the encryption settings for your database backups. See the reference entries for those commands for more details.
Binary Compression of Backup Sets
RMAN can apply a binary compression algorithm as it writes data to backup sets. This compression is similar to the compression provided by many tape vendors when backing up data to tape. (The two types of compression should not be used together; see the discussion of BACKUP AS BACKUPSET
below for details on choosing between using RMAN compression and the tape compression for backup sets.)
Unused Block Compression Of Datafile Backups to Backup Sets
When backing up datafiles into backup sets, RMAN does not back up the contents of data blocks that have never been allocated. (In previous releases, this behavior was referred to as NULL compression.)
RMAN also skips other datafile blocks that do not currently contain data, if all of the following conditions apply:
The COMPATIBLE
initialization parameter is set to 10.2
There are currently no guaranteed restore points defined for the database
The datafile is locally managed
The datafile is being backed up to a backup set as part of a full backup or a level 0 incremental backup
The backup set is being created on disk.
Skipping unused data blocks where possible enables RMAN to back up datafiles using less space, and can make I/O more efficient.
Backup Optimization
The BACKUP
command optimizes backups, that is, does not back up files that are identical to files that are already backed up, when the following conditions are met:
The CONFIGURE
BACKUP
OPTIMIZATION
ON
command has been run.
You run BACKUP
DATABASE
, BACKUP
ARCHIVELOG
with ALL
or LIKE
options, or BACKUP
BACKUPSET
ALL
.
You specify a channel of only one device type, that is, you do not mix channels that use different device types.
Channel Failover
A BACKUP
command is decomposed into multiple independent backup steps by RMAN. Each independent step can be executed on any channel allocated for a specific device. If you have multiple channels allocated, and one channel fails or encounters a problem during a backup step, then RMAN attempts to complete the work on another channel. RMAN reports a message in V$RMAN_OUTPUT
and in the output to the interactive session or log file when channel failover occurs.
Control File Autobackups
If CONFIGURE CONTROLFILE
AUTOBACKUP
is set to ON
, then RMAN automatically backs up the control file after BACKUP
commands. "CONFIGURE" describes the complete set of circumstances in which autobackups occur.
Restrictions and Usage Notes
Although the database depends on other types of files for operation, such as network configuration files, password files, and the contents of the Oracle home, these files cannot be backed up with RMAN. Likewise, some features of Oracle, such as external tables or the BFILE datatype, store data in files other than those listed above. RMAN cannot back up those files. You must use some non-RMAN backup solution for any files not in the preceding list.
The target database must be mounted or open when using the RMAN BACKUP
command.
RMAN can make an inconsistent backup when the database is in ARCHIVELOG
mode, but you must apply redo logs after restoring such a backup, to make the database consistent.
You must use a current control file when using the BACKUP
command.
If no automatic channel is configured for the specified device type, then you must manually allocate a channel for each execution of the BACKUP
command. If no manual channel is allocated, then RMAN uses the default channels (as set using the CONFIGURE command). RMAN comes with a DISK
channel preconfigured but no preconfigured channels for sbt
devices.
Note: Backups that use the disk test API are not supported for production backups. Instead, use the preconfiguredDISK channel or manually allocate a DISK channel. |
Backup pieces must have unique names.
When backing up Oracle files to DISK
, the logical block size of the Oracle file to be backed up must be an even multiple of the physical block size of the destination device. For example, a DISK
device with a block size of 2K can only be used as a destination for backups of Oracle files with logical block sizes of 2K, 4K, 6K and so on. In practice, most disk drives have physical block sizes of 512 bytes, so this limitation rarely affects backup. However, you can encounter this limitation when using BACKUP
... DEVICE
TYPE
DISK
to back your database up to a writeable CD or DVD, or some other device which has a larger physical block size.
You must back up files onto valid media. If you specify DEVICE
TYPE
DISK
, then RMAN will back up to random access disks. You can make a backup on any device that can store a datafile: in other words, if the statement CREATE
TABLESPACE
tablespace_name
DATAFILE
'filename'
works, then 'filename'
is a valid backup path name. If you specify DEVICE
TYPE
sbt
, then you can back up to any media supported by the media manager.
You can only backup a database running in NOARCHIVELOG
mode after a consistent shutdown. You cannot make a backup (either normal or incremental) in NOARCHIVELOG
mode when the database is open or is closed after an instance failure or SHUTDOWN ABORT
.
You cannot stripe a single backup set across multiple channels.
You cannot stripe a single input file across multiple backup sets.
Archived redo log files and datafiles are never combined into a single backup set.
When using encrypted backups, datafiles from tablespaces with different encryption settings are never written into the same backup set.
There is no persistent configuration that controls whether archivelog backups as backupsets are encrypted. Backup sets containing archived logs are encrypted if any of the following are true:
SET
ENCRYPTION
ON
is in effect at the time that the archive log backup is being created.
Encryption is configured for backups of the whole database or at least one tablespace.
You cannot specify multiple, identical FORMAT
strings within a single backupSpec
(for example, BACKUP
DATAFILE
3
TO
'/tmp/foo',
DATAFILE
4
TO
'/tmp/foo'
). However, RMAN permits a single FORMAT
string to exist in multiple backupSpec
clauses.
You canot back up files with different block sizes into the same backup set. RMAN can back up tablespaces with different block sizes, but puts each differently sized datafile into its own backup set.
You cannot back up locally-managed temporary tablespaces (although you can back up dictionary-managed tablespaces)
You cannot back up transportable tablespaces that were not made read-write after being transported.
You cannot use the DELETE
INPUT
option when backing up objects other than datafile copies, archived redo logs, or backup sets.
You cannot specify the number of backup pieces that should go in a backup set.
You cannot create image copies (that is, use BACKUP
AS
COPY
) on a nondisk media device.
You cannot back up a backup set from tape to disk, or from one tape to another tape.
You cannot make an image copy of a backup set, although you can make an image copy of an image copy. To backup a backupset, use BACKUP
BACKUPSET
.
You cannot specify the PLUS
ARCHIVELOG
clause on the BACKUP
ARCHIVELOG
command.
Do not open a NOARCHIVELOG
mode database while it is being backed up. If you do, and some data blocks in the files being backed up are modified before being read by the backup session, then the backup is not usable after being restored because it requires recovery.
The maximum length of a backup piece filename is platform-specific. For SBT backups using a media manager, the length is also limited by the limit in the supported version of the media management API. Vendors supporting SBT 1.1 must support filenames up to 14 characters. Some SBT1.1 vendors may support longer filenames. Vendors supporting SBT 2.0 must support filenames up to 512 characters. Some SBT2.0 vendors may support longer filenames.
You cannot use the DEVICE
TYPE
option for a device other than DISK
if you have not already run CONFIGURE
DEVICE
TYPE
for this device.
You cannot allocate channels and run BACKUP
with the DEVICE
TYPE
option.
You cannot validate the backup of backup sets.
You cannot specify DEVICE
TYPE
DISK
when running the BACKUP
RECOVERY
AREA
command.
You cannot back up the change tracking file with RMAN.
Keywords and Parameters
backup
backupOperand
Syntax Element | Description |
---|---|
backupOperand |
Specifies various options for the BACKUP command. |
backupTypeSpec |
Specifies the type of backup being created, either backup sets or image copies. See "backupTypeSpec" for details. |
CHANNEL channel_id |
Specifies the case-sensitive name of a channel to use when creating backups. Use any name that is meaningful, for example ch1 or dev1 . The database uses the channel ID to report I/O errors. If you do not set this parameter, then RMAN dynamically assigns the backup sets to any available channels during execution.
Note: You can also specify this parameter in the |
CHECK LOGICAL |
Tests data and index blocks that pass physical corruption checks for logical corruption, for example, corruption of a row piece or index entry. If RMAN finds logical corruption, then it logs the block in the alert.log and server session trace file.
If the sum of physical and logical corruptions detected for a file is no more than its If the initialization parameter Note: The |
COPIES = integer |
Sets the number of identical backups (1 - 4 ) that RMAN should create. The default value is 1 . You can specify duplexing on more than one command. The order of precedence is as follows, with settings higher on the list overriding lower settings:
Note: This option does not apply with Note: Duplexing cannot be used when creating files in the flash recovery area. |
CUMULATIVE |
Copies the data blocks used since the most recent backup at level 0 or lower, where n is 1. For example, in a cumulative level 1 backup RMAN backs up all blocks used since the most recent level 0 backup.
Note: This option does not apply with |
DEVICE TYPE deviceSpecifier |
Allocates automatic channels for the specified device type only. This option is valid only if you have configured channels and have not manually allocated channels. For example, if you configure disk and tape channels, then configure sbt as the default device type, this command allocates disk channels only:
BACKUP DEVICE TYPE DISK DATABASE; See Also: "deviceSpecifier" |
DISKRATIO [=] integer |
Directs RMAN to populate each backup set with datafiles from at least integer disks. This parameter is only enabled when you are backing up datafiles or control files, and when the operating system can give RMAN disk contention and node affinity information. To manually disable this feature, set DISKRATIO = 0 .
For example, assume that datafiles are distributed across 10 disks. If the disks supply data at 10 bytes/second, and if the tape drive requires 50 bytes/second to keep streaming, then set If you set The DISKRATIO parameter is easier for datafile backups when the datafiles are striped or reside on separate disk spindles and you either:
Note: Do not spread I/O over more than the minimum number of disks required to keep the tape streaming. Otherwise, you increase restore time for a file without increasing performance. |
duration |
Specifies options related to the maximum time for a backup command to run.
See Also: "duration" |
filenameConversionSpec |
This option is valid only when BACKUP is creating image copies. Files being copied are renamed according to the specified patterns. If a file being backed up has a name that does not match any of the specified rename patterns, then RMAN uses FORMAT to name the output image copies. If no FORMAT was specified, then RMAN uses the default format %U .
See "fileNameConversionSpec" for details about file renaming patterns. |
FILESPERSET [=] integer |
When used with commands that create backupsets, specifies the maximum number of files to include in each backupset created.
By default, RMAN divides files among backupsets in order to make optimal use of channel resources. The number of files to be backed up is divided by the number of channels. If the result is less than 64, then it is the number of files placed in each backupset. Otherwise, 64 files will be placed in each backupset. |
FORCE |
Causes RMAN to ignore backup optimization. In other words, even if CONFIGURE BACKUP OPTIMIZATION is set to ON , RMAN backs up all specified files.
Note: You can also specify this option in the |
FORMAT = formatSpec |
Specifies a pattern to use in creating a filename for the backup pieces or image copies created by this command. For AS COPY , if one or more of the directories mentioned in the specified format do not exist, then RMAN signals an error.
See Also: "formatSpec" for legal substitution variables |
forRecoveryOfSpec |
Identifies the backup being created as an incremental backup to be used in rolling forward an image copy. See "forRecoveryOfSpec" for details. |
FULL |
Creates a backup of all blocks of datafiles included in the backup. FULL is the opposite of INCREMENTAL .
RMAN makes full backups by default if neither A full backup has no effect on subsequent incremental backups, and is not considered a part of any incremental backup strategy (though a full image copy backup can be incrementally updated by applying incremental backups with the RECOVER command). Note:Backup Unused Space Compression, described in "Unused Block Compression Of Datafile Backups to Backup Sets", causes some datafile blocks to be skipped during full backups of datafiles as backup sets. |
INCREMENTAL LEVEL [=] integer |
Copies only those data blocks that have changed since the last incremental integer backup, where integer is 0 or 1 . An incremental backup at level 0 backs up all data blocks in datafiles being backed up. An incremental backup at level 1 backs up only changed blocks. An incremental backup can be either differential or cumulative.In a cumulative level 1 incremental backup, RMAN backs up all blocks changed since the most recent level 0 backup. In a differential level 1 incremental backup, RMAN backs up blocks updated since the last level 0 or level 1 incremental backup.
Incremental backups at level 0 can be either backup sets or image copies. Incremental backups at level 1 can only be backup sets. A level 0 backup must exist as the base backup for an incremental strategy. An incremental backup at level 0 is identical in content to a full backup, but unlike a full backup the level 0 backup is considered a part of the incremental strategy. If no level 0 backup exists when you run a level 1 backup, then RMAN makes a level 0 backup automatically. The database performs checks when attempting to create a level 1 incremental backup, to ensure that the incremental backup is usable by a subsequent RECOVER command. Among the checks performed are:
If you specify Note: You cannot make inconsistent incremental backups when the database is in Note: When creating an incremental backup, RMAN considers backups from parent incarnations as valid. For example, assume you make a level 0 backup and then See Also: "CHANGE" |
INCREMENTAL FROM SCN = integer |
Creates an incremental backup of all specified datafiles which includes all datafile blocks changed at SCNs greater than or equal to the specified SCN.
The expected use of this feature is in refreshing a standby database with changes from a primary database. See Oracle Database Backup and Recovery Advanced User's Guide for details. Note:
|
keepOption |
Overrides any configured retention policy for this backup so that the backup is not considered obsolete. You can use CHANGE to alter the keep status. Note that you must be connected to a recovery catalog when you specify KEEP FOREVER .
See Also: "keepOption" |
MAXSETSIZE = integer [ K | M | G ] |
Specifies a maximum size for a backup set.RMAN limits all backup sets to this size. Use MAXSETSIZE to configure backup sets so that each fits on one tape rather than spanning multiple tapes. Otherwise, if one tape of a multivolume backup set fails, then you lose the data on all the tapes rather than just one.
Specify size in bytes (default), kilobytes ( The default number of files in each backup set is 4 for datafiles and 16 for archived logs. When you specify Note: This option cannot be used with |
NOCHECKSUM |
Suppresses block checksums. A checksum is a number that is computed from the contents of a data block. If the DB_BLOCK_CHECKSUM initialization parameter is true , then the database computes a checksum for each block during normal operations and stores it in the block before writing the block to disk. When the database reads the block from disk later, it recomputes the checksum and compares it to the stored value. If they do not match, then the block is damaged.
By default, the database also computes a checksum for each block and stores it in the backup. The checksum is verified when restoring from the backup and written to the datafile when restored. If the database is already maintaining block checksums, then this flag has no effect. The checksum is always verified and stored in the backup in this case. If you wish to prevent the use of block checksums in your backup, use the See Also: Oracle Database Reference for more information about the |
notBackedUpSpec |
Limits the set of files to be backed up according to whether a specified number of backups are already present (and not obsolete), or whether the files have been backed up since a specified date. See "notBackedUpSpec" for details. |
NOEXCLUDE |
When specified on BACKUP DATABASE or BACKUP COPY OF DATABASE command, RMAN backs up all tablespaces, including any for which a CONFIGURE EXCLUDE command has been entered. This option does not override SKIP OFFLINE or SKIP READONLY . |
POOL = integer |
Specifies the media pool in which the backup should be stored. Consult your media management documentation to see whether the POOL option is supported.
Note: This option does not apply with |
PROXY |
Backs up the specified files by means of the proxy copy functionality, which gives the media management software control over the data transfer between storage devices and the datafiles on disk. The media manager—not RMAN—decides how and when to move data.
When you run
If you do not want RMAN to try a conventional copy when a proxy copy fails, use the Note: If you specify Note: This option cannot be used with |
ONLY |
Causes the database to issue an error message when it cannot proxy copy rather than creating conventional backup sets. |
REUSE |
Enables RMAN to overwrite an already existing backup or copy with the same filename as the file that BACKUP is currently creating. |
skipSpec |
Excludes datafiles or archived redo logs from the backup if they are inaccessible, offline or read-only. See "skipSpec" for details. |
TAG tag_name |
Creates a user-specified tag name for a backup. The tag is not case sensitive.
If you do not specify a tag name, then by default RMAN creates a tag for backups (except for control file autobackups) in the format A tag applies to each backup piece in a given copy of a backup set (for Typically, a tag is a meaningful name such as Tags must be 30 characters or less. The characters used in a tag must be limited to the characters that are legal in filenames on the target filesystem. For example, ASM does not support the use of the You can also specify the tag at the
|
VALIDATE |
Causes RMAN to scan the specified files and verify their contents, testing whether this file can be backed up. RMAN creates no output files. Use this command periodically to check for physical and logical errors in database files.
Note: You cannot validate backups of backup sets. |
backupSpec
Syntax Element | Description |
---|---|
backupSpec |
A BACKUP specification list contains a list of one or more backupSpec clauses. A backupSpec clause contains, at a minimum, a list of one or more objects to be backed up.
Each |
archivelogRecordSpecifier |
Specifies a range of archived redo logs to be backed up. RMAN does not signal an error if the command finds no logs to back up, because this situation probably exists because no new logs were generated after the previous BACKUP ARCHIVELOG ALL DELETE INPUT command.
If you specify If the database is open when you run Note: If you run See Also: "archivelogRecordSpecifier" for syntax, and Oracle Database Backup and Recovery Advanced User's Guide explanations of backup failover for logs and automatic log switching |
BACKUPSET { ALL | completedTimeSpec | primaryKey [, primaryKey ]} |
Backs up either ALL backup sets or backup sets specified by primary_key or completion time. Use this parameter in conjunction with the DEVICE TYPE sbt clause to back up all backups on disk to tape. You cannot back up from tape to tape or from tape to disk: only from disk to disk or disk to tape.
Note if you specify the RMAN performs backup set failover when backing up backup sets. RMAN searches for all available backup copies when the copy that it is trying to back up is corrupted or missing. This behavior is similar to RMAN's behavior when backing up archived logs that exist in multiple archiving destinations. Note: You can duplex backups of backup sets by using See Also: "completedTimeSpec" |
CONTROLFILECOPY { ' filename ' | ALL | LIKE ' string_pattern ' } |
Specifies a control file copy in one of the following ways:
The control file copy can be:
RMAN inspects the header of the control file copy to determine whether it is a standby or nonstandby control file. |
copyOfSpec |
Makes a backup of previous image copies of datafiles and possibly control files. See "copyOfSpec" for details. |
CURRENT CONTROLFILE [FOR STANDBY] |
Specifies the current control file.
If you specify Note: You cannot assign a tag to a backup of the current control file. |
DATABASE |
Creates a backup set (AS BACKUPSET ) or group of image copies (AS COPY ) for all datafiles in the database. If generating a backup set, then RMAN can include only datafiles and control files: it cannot include archived redo logs.
If the If the Note: To force RMAN to include the current control file in the backup when |
datafileCopySpec |
Specifies the filenames of one or more datafile image copies. See "datafileCopySpec" for details. |
DATAFILE datafileSpec |
Specifies a list of one or more datafiles. Refer to description of BACKUP DATABASE for RMAN behavior when datafile 1 is backed up.
See Also: "datafileSpec" |
RECOVERY AREA | DB_RECOVERY_FILE_DEST |
Backs up recovery files created in the current and all previous flash recovery area destinations. Recovery files are full and incremental backup sets, control file autobackups, archived logs, and datafile copies. Flashback logs, the current control file, and online redo logs are not backed up.
Backup optimization is always Note: If the flash recovery area is not enabled but has been enabled in the past, then files that were created in the previous flash recovery area location are backed up. |
RECOVERY FILES |
Backs up all recovery files on disk, whether they are stored in the flash recovery area or another locations on disk. Recovery files include full and incremental backup sets, control file autobackups, archived logs, and datafile copies. Backup optimization is always ON for this option. The backup must go to sbt , so RMAN issues an error if no sbt channels are allocated or configured. |
SPFILE |
Backs up the server parameter file currently used by the database. RMAN cannot back up other copies of the server parameter file, and cannot back up the server parameter file when the instance was started with an initialization parameter file. RMAN cannot make incremental backups of the SPFILE . |
TABLESPACE tablespace_name [ , tablespace_name ] |
Specifies the names of one or more tablespaces. RMAN backs up all datafiles that are currently part of the tablespaces. If the SYSTEM tablespace (and thus datafile 1 ) is included in the backup, and if CONTROLFILE AUTOBACKUP is not configured, then RMAN creates a copy of the control file.
The |
backupSpecOperand |
The backupSpecOperand that follows a backupSpec specifies options that apply to the backupSpec. |
backupSpecOperand
Syntax Element | Description |
---|---|
backupSpecOperand |
Specifies a variety of options and parameters that affect the backupSpec clause. Many subclauses of backupSpecOperand are also used with backupOperand. For those, see the description of "backupOperand". Those which are not shared in common with backupOperand are listed here. |
DELETE [ ALL ] INPUT |
Deletes the input files upon successful creation of the backup. Specify this option only when backing up archived logs, datafile copies (COPY OF or DATAFILECOPY ), or backup sets. It is equivalent to issuing DELETE for the input files.
The Note: The See Also: "CONNECT" for information on the effect of recovery catalog compatibility on this command |
FROM TAG = 'tag_name' |
Allows specifying a backup by tag. Defined in context with several other commands. |
INCLUDE CURRENT CONTROLFILE [FOR STANDBY] |
Creates a snapshot of the current control file and places it into each backup set produced by this clause.
If you specify Note: This option does not apply with |
backupTypeSpec
Syntax Element | Description |
---|---|
AS [ COMPRESSED ] BACKUPSET |
Creates backup sets (rather than image copies) on the specified device type.
When backing up datafiles into backup sets, RMAN only backs up blocks that are currently in use. With the Note:
|
AS COPY |
Creates image copies (rather than backup sets). Can only be used with backups created on disk.
Note: When using
|
copyOfSpec
Syntax Element | Description |
---|---|
COPY OF DATABASE |
Makes a backup of previous image copies of all datafiles and control files in the database. All datafiles that would normally be included by BACKUP DATABASE are expected to have copies: if not, then RMAN signals an error. It is not necessary for all copies to have been produced by a single BACKUP command. If multiple copies exist of datafile, then RMAN backs up the latest. Optionally, specify the copies by tag name (for example, FULL_COLD_COPY ).
Note: The output of this command can be image copies or backup sets. |
COPY OF TABLESPACE tablespace_name |
Makes a backup of previous image copies of the datafiles in one or more specified tablespaces. All datafiles that would normally be included by BACKUP TABLESPACE should have copies: if not, then RMAN signals an error. It is not necessary for all copies to have been produced by a single BACKUP command. If multiple copies exist of datafile, then RMAN backs up the latest.
Specify the tablespaces in the list by tablespace name (for example, Note: The output of this command can be image copies or backup sets. |
COPY OF DATAFILE datafileSpec |
Makes a backup of a previous image copy of one or more datafiles. Specify the datafile by file number (DATAFILE 3 ) or filename (DATAFILE '?/oradata/trgt/users01.dbf' ). You specify the datafile filename and not the filename of the copy of the datafile. If more than one copy exists of a given datafile, then RMAN backs up the most recent copy.
Note: It is not necessary for the image copies that you are backing up to have been created by a single Note: The output of this command can be image copies or backup sets. See Also: "datafileSpec" |
datafileCopySpec
Syntax Element | Description |
---|---|
DATAFILECOPY { filename [,filename...]|{ ALL | LIKE 'string_pattern' | FROM TAG 'tag_name' }
} |
Specifies the filenames of one or more datafile image copies. You can use the following parameters:
|
NODUPLICATES |
Prevents the inclusion of identical datafile copies in a backup operation. For each set of duplicate datafile copies, the file with the most recent timestamp will be selected. |
duration
Syntax Element | Description |
---|---|
DURATION hh:mm
|
Specifies a maximum time for a backup command to run. If a backup command does not complete in the specified duration, the backup being taken stops.
With the Without the Whether With disk backups, you can use When |
forRecoveryOfSpec
Syntax Element | Description |
---|---|
FOR RECOVER OF TAG [=] ' tag_name ' |
Lets you identify any tagged level 0 incremental to serve as the basis for this level 1 incremental. Useful in strategies other than the incrementally updated backups strategy, which uses the FOR RECOVER OF COPY clause. |
FOR RECOVER OF COPY |
Lets you specify that this incremental should contain all changes since the SCN of a specified datafile copy (level 0 incremental backup) of your database. The datafile copies should be identified with either a DATAFILE COPY or WITH TAG clause, to keep the incremental backup strategy for which this backup will be used separate from the rest of your backup strategies. Otherwise, the most recent copy of each datafile will be used as the basis for the incremental. |
WITH TAG [=] 'tag_name' |
Used with FOR RECOVER OF COPY , specifies a tag to identify the level 0 incremental backup to serve as the basis of the incremental. If no level 0 with the tag specified in WITH TAG option is found, then FOR RECOVER OF COPY option will create a level 0 datafile copy tagged with the value specified in the WITH TAG option. BACKUP... FOR RECOVER OF COPY WITH TAG ... is key to backup strategies based on incrementally updated backups, as described in Oracle Database Backup and Recovery Basics and used in some Enterprise Manager backup strategies. |
DATAFILE COPY [=] formatSpec |
Used with FOR RECOVER OF COPY , identifies the datafile copies to use as the basis for this incremental. |
notBackedUpSpec
Syntax Element | Description |
---|---|
NOT BACKED UP |
Backs up only those files (of the files specified on the command) that RMAN has never backed up. This option is a convenient way to back up new files after adding them to the database. |
SINCE TIME = 'date_string ' |
Specifies the date after which RMAN should back up files that have no backups. The date_string is either a date in the current NLS_DATE_FORMAT , or a SQL date expression such as 'SYSDATE-1' . When calculating the number of backups for a file, RMAN only considers backups created on the same device type as the current backup.
This option is a convenient way to back up files that were not backed up during a previous failed backup. For example, you back up the database, but the instance fails halfway through. You can restart the backup with the When determining whether a file has been backed up, the |
integer TIMES |
Backs up only those archived logs that have not been backed up at least integer times. To determine the number of backups for a file, RMAN only considers backups created on the same device type as the current backup.
This option is a convenient way to back up archived logs on a specified media (for example, you want to keep at least three copies of each log on tape). |
sizeSpec
Syntax Element | Description |
---|---|
integer [K|M|G] |
Specifies the size of data, such as a file, in kilobytes (K), megabytes (M) or gigabytes (G). |
skipSpec
Syntax Element | Description |
---|---|
SKIP |
Excludes datafiles or archived redo logs from the backup according to the criteria specified by the following keywords.
Note: You can also specify this option in the |
INACCESSIBLE |
Specifies that datafiles or archived redo logs that cannot be read due to I/O errors should be excluded from the backup.
A datafile is only considered inaccessible if it cannot be read. Some offline datafiles can still be read because they still exist on disk. Others have been deleted or moved and so cannot be read, making them inaccessible. |
OFFLINE |
Specifies that offline datafiles should be excluded from the backup. |
READONLY |
Specifies that read-only datafiles should be excluded from the backup. |
Examples
Backing Up a Database: Example This example assumes that CONFIGURE
CONTROLFILE
AUTOBACKUP
is OFF
. The command backs up all datafiles to tape, as well as the current control file, the server parameter file, and archived logs:
BACKUP DATABASE PLUS ARCHIVELOG;
Scripting Incremental Backups: Example This example shows a series of scripts that you can run to make regular incremental backups of the database:
# Run once a week to back up database to disk as level 0: BACKUP INCREMENTAL LEVEL 0 DATABASE; # Run every day 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;
Performing a Cumulative Incremental Backup: Example This example backs up all blocks changed in the database since the most recent level 0 backup:
BACKUP INCREMENTAL LEVEL 1 CUMULATIVE SKIP INACCESSIBLE DATABASE;
Backing Up Tablespaces and Datafiles to Disk as Backup Sets: Example This command uses two backupSpec
clauses to back up tablespaces and datafiles and lets RMAN perform automatic parallelization of the backup:
RUN { ALLOCATE CHANNEL dev1 DEVICE TYPE DISK FORMAT '/disk1/%U'; ALLOCATE CHANNEL dev2 DEVICE TYPE DISK FORMAT '/disk2/%U'; BACKUP AS BACKUPSET (TABLESPACE SYSTEM, tools, users, undotbs MAXSETSIZE 5M) (DATAFILE 2,4,5); }
Backing Up Tablespaces and Datafiles to Disk as Image Copies: Example This command uses two backupSpec
clauses to back up tablespaces and datafiles and lets RMAN perform automatic parallelization of the backup:
RUN { ALLOCATE CHANNEL dev1 DEVICE TYPE DISK FORMAT '/disk1/%U'; ALLOCATE CHANNEL dev2 DEVICE TYPE DISK FORMAT '/disk2/%U'; BACKUP AS COPY (TABLESPACE SYSTEM, tools, users, undotbs) (DATAFILE 2,4,5); }
Backing Up Datafile Copies: Example This example finds three datafile copies with the tag LATESTCOPY
, copies them to directory /copies
and names the new copies by means of subsitution variables:
BACKUP AS COPY FROM TAG 'LATESTCOPY' COPY OF DATAFILE 4, 6, 14 FORMAT '/copies/Datafile%f_Database%d';
Backing Up Archived Logs and Deleting the Input: Example This example assumes that you have two archive destinations set: /arch1
and /arch2
. The command backs up one log for each unique sequence number and then deletes all logs from both archiving directories.
BACKUP ARCHIVELOG LIKE '/arch%' DELETE ALL INPUT;
Backing Up Backup Sets to Tape: Example In this example, the goal is to keep recent backup sets on disk and older backup sets on tape, and to avoid keeping copies of the same backup set on disk and tape simultaneously. This command backs up backup sets created more than two weeks ago to tape and then deletes the backed-up backup pieces from disk:
BACKUP DEVICE TYPE sbt BACKUPSET COMPLETED BEFORE 'SYSDATE-14' DELETE INPUT;
Specifying DEVICE TYPE on the BACKUP Command: Example This example configures DISK
as the default device type, then backs up the server parameter file and all archived logs to tape:
# when disk is the default device and you do not specify a FORMAT parameter, then the # default backup location is the flash recovery area (if configured) or # a platform-specific default location (if not configured) CONFIGURE DEFAULT DEVICE TYPE TO DISK; BACKUP DEVICE TYPE sbt SPFILE ARCHIVELOG ALL;
Duplexing a Backup Set: Example This example duplexes a backup of datafile 1
(which includes the current control file and server parameter file) to separate disks:
BACKUP DEVICE TYPE DISK COPIES 2 DATAFILE 1 FORMAT '/disk1/df1_%U', '/disk2/df1_%U';
Specifying How Channels Divide Workload: Example This example explicitly parallelizes a backup operation by specifying which channels should back up which files and to which locations:
RUN { ALLOCATE CHANNEL ch1 DEVICE TYPE sbt PARMS="ENV=(NSR_SERVER=tape_server_1)"; ALLOCATE CHANNEL ch2 DEVICE TYPE DISK; ALLOCATE CHANNEL ch3 DEVICE TYPE sbt PARMS="ENV=(NSR_SERVER=tape_server_2)"; BACKUP (DATAFILE 1,2,3,4 # channel ch1 backs up datafiles to tape drive #1 CHANNEL ch1) (CONTROLFILECOPY '/oracle/copy/cf.f' CHANNEL ch2) # channel ch2 backs up control file copy to disk (ARCHIVELOG FROM TIME 'SYSDATE-14' CHANNEL ch3); # channel ch3 backs up archived redo logs to tape drive #2 }
Creating a Control File for a Standby Database: Example This example creates a backup of the current control file that can be used to create a standby database:
BACKUP CURRENT CONTROLFILE FOR STANDBY;
Creating an Incremental Backup for Refresh of a Standby Database: Example This example creates an incremental backup at a primary database that can be applied at a standby database to update it with changes since the specified SCN, as described inOracle Database Backup and Recovery Advanced User's Guide .
BACKUP DEVICE TYPE DISK INCREMENTAL FROM SCN 750983 DATABASE FORMAT '/tmp/incr_standby_%U';
Backing Up Datafiles, Tolerating Corrupt Blocks: Example This example backs up datafile 3
and specifies that no more than two blocks with corruption should be tolerated:
RUN { SET MAXCORRUPT FOR DATAFILE 3 TO 2; BACKUP CHECK LOGICAL DATAFILE 3; }
Making an Image Copy of a Database Copy: Example This example makes an image copy of the database copy with tag TEST
to the default destination, gives the output copy the tag DUPTEST
, and performs logical checking:
BACKUP AS COPY COPY OF DATABASE FROM TAG 'TEST' CHECK LOGICAL TAG 'DUPTEST';
Creating a Long-Term Database Backup: Example This example creates a consistent backup of the database and server parameter file that is exempt from the retention policy. The command instructs RMAN to keep the backup for the next year, but not to keep the archived logs necessary to recover it:
SHUTDOWN IMMEDIATE; STARTUP MOUNT; BACKUP DATABASE KEEP UNTIL TIME 'SYSDATE+365' NOLOGS; ALTER DATABASE OPEN;
Exempting Copies from the Retention Policy: Example The following example copies the control file and two datafiles and exempts them from the retention policy forever. (Note that KEEP FOREVER
requires a recovery catalog.)
rman TARGET / CATALOG rman/rman@rcat RMAN> SHUTDOWN IMMEDIATE; RMAN> STARTUP MOUNT; RMAN> BACKUP AS COPY KEEP FOREVER NOLOGS CURRENT CONTROLFILE FORMAT '?/oradata/cf_longterm.cpy', DATAFILE 1 FORMAT '?/oradata/df1_longterm.cpy', DATAFILE 2 FORMAT '?/oradata/df2_longterm.cpy'; ALTER DATABASE OPEN;
Backing Up Files That Need Backups: Example This example backs up all datafiles that have not been backed up to tape in the last month, and then backs up all archived logs that do not have at least two backups on tape:
BACKUP DEVICE TYPE sbt DATABASE NOT BACKED UP SINCE TIME 'SYSDATE-31'; BACKUP DEVICE TYPE sbt ARCHIVELOG ALL NOT BACKED UP 2 TIMES;
Using NODUPLICATES To Back Up Datafile Copies: Example This example creates several duplicate datafiles, and then backs up only the most recent of the duplicates:
BACKUP AS COPY DATAFILE 10 FORMAT 'foo' TAG my_tag; BACKUP AS COPY DATAFILECOPY 'foo' FORMAT 'bar'; BACKUP AS COPY DATAFILECOPY 'bar' FORMAT 'foobar'; BACKUP AS BACKUPSET DATAFILECOPY ALL NODUPLICATES; # backs up only 'foobar' BACKUP AS BACKUPSET DATAFILECOPY ALL; # backs up all files