| Oracle® Database Backup and Recovery Advanced User'
s Guide 10g Release 1 (10.1) Part Number B10734-01 |
|
tr>
![]() Previous ![]() Next |
This chapter describes how to use RM AN to make backups. This chapter contains these topics:
When backing up to disk, it is recommended to create image copies, rather than backup set
s. Some features of RMAN backups, such as incrementally updated backups, require the use of image copies. Also, image copy backups ar
e more convenient to use in some restore and recovery scenarios. However, by default, the BACKUP command creates backups
as backup sets, when backing up to disk as well as to tape. (Backups to tape must be stored as backup sets.)
To configure RMAN to create image copies by default when backing up to disk, use the following command:
RMAN> CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COPY;
To return RMAN to its default behavior of producing backup sets, use the following command:
RMAN> CONFIGURE DEVICE TYPE DISK BACKUP TYPE CLEAR;
It is safer to make multiple copies of backups to protect against disaster, media
damage, or human error. RMAN can make up to four copies of a backup set simultaneously, each an exact duplicate of the others. A copy
of a backup set is a copy of each backup piece in the backup set, with each copy getting a unique copy number (for example, 0t
cm8u2s_1_1 and 0tcm8u2s_1_2).
In most cases, the easiest method is to u
se BACKUP... COPIES or CONFIGURE ... BACKUP COPIES to d
uplex backup sets. There is little value in creating multiple copies on the same physical media. For DISK channels, spec
ify multiple values in the FORMAT option to direct the multiple copies to different physical disks. For sbt
channels, if you use a media manager that supports Version 2 of the SBT API, then the media manager will automatically put each copy
onto a separate medium (for example, a separate tape).
Note that it is not possible to dup
lex backup sets to the flash recovery area, and that duplexing only applies to backup sets, not image copies. It is an error to speci
fy the BACKUP... COPIES when creating image copy backups, and the CONFIGURE... BACKUP COPIES setting is ign
ored for image copy backups.
The CONFIGURE ... BACKUP COPIES command specifies the number of identical back
up sets that you want to create on the specified device type. This setting applies to all backups except control file autobackups (be
cause the autobackup of a control file always produces one copy) and backup sets when backed up with the BACKUP BACKUPSET command. You must have automatic channels configured.
To duplex a ba ckup with CONFIGURE BACKUP COPIES:
BACKUP command. Th
e following command backs up the database and archived logs to tape, making two copies of each datafile and archived redo log:
RMAN> BACKUP DATABASE PLUS ARCHIVELOG; # uses default sbt channel
Because of the configured formats for the disk channel, the following command backs up the dat
abase to disk, placing one copy of the backupsets produced in the /save1 directory and the other in the /save2 directory:
RMAN> BACKUP DEVICE TYPE DISK AS COPY DATABASE; < /pre>
LIST BACKUP command to see a l
isting of backup sets and pieces . For example, enter:
RMAN> LIST BACKUP SUMMARY;
The #Copies column shows the number of backupsets, which ma
y have been produced by duplexing or by multiple backup commands.
The COPIES option of the BACKUP command overrides every other DUPLEX setting to control duplexing of backupsets.
To duplex a backup with BACKUP COPIES:
COPIES option of the BACKUP command. For ex
ample, run the following to make three copies of each backup set in the default DISK location:
RMAN> BACKUP AS BACKUPSET DEVICE TYPE DISK COPIES 3 INCREMENTAL L EVEL 0 DATABASE;
Because you specified
COPIES on the BACKUP command, RMAN makes three backupsets of each datafile regardless of the CONFIGUR
E DATAFILE COPIES setting.
LIST BACKUP command to see a listing of backup sets and pieces (the #Copies column shows the
number of copies, which may have been produced through duplexing or through multiple invocations of the BACKUP command).
For example, enter:
RMAN> LIST BACKUP SUMMARY;
Many sites keep an backup of the database sto
red on disk in case a failure occurs on the primary database or an incorrect user action such as a DROP TABLE requires point-in-time recovery. A datafile backup on disk simplifies the restore step of recovery, making recovery much quicker a
nd more reliable.
One way of creating a datafile backup on disk is to use disk mirrorin g. For example, you can use the operating system to maintain three identical copies of each file in the database. In this configurati on, you can split off a mirrored copy of the database to use as a backup.
RMAN does not aut omate the splitting of mirrors, but can make use of split mirrors in backup and recovery operations. For example, RMAN can treat a sp lit mirror of a datafile as a datafile copy, and can also back up this copy to disk or tape.
The following procedure shows how to make a split mirror backup with the SUSPEND/RESUME functionality. Th
e SUSPEND/RESUME feature is not required for split mirror backups in most cases, although it is necessary if your system
requires the database cache to be free of dirty buffers before the volume can be split.
To make a split mirror backup of a tablespace by using SUSPEND/RESUME:
ALTER TABLESPACE ... BEGIN BACKUP statement. (To place
all tablespaces in backup mode, you can use ALTER DATABASE BEGIN BACKUP instead.)
For example, to place tablespace users in backup mode, start RMAN and run the following commands:
RMAN> CONNECT TARGET SYS/oracle@trgt RMAN> CONNECT CATALOG rman/cat@catdb < a name="1006235">RMAN> SQL 'ALTER TABLESPACE users BEGIN BACKUP';
RMAN> SQL 'ALTER SYSTEM SUSPEND';
RMAN> SQL 'ALTER SYSTEM RESUME';
RMAN> SQL 'ALTER TABLESPACE users END BACKUP';
You could also use ALTER DAT
ABASE END BACKUP to take all tablespaces out of backup mode.
CATALOG command. For
example, enter:
RMAN> CATALOG DATAFILECOPY '/dk2/oradata/trgt/users01.dbf'; # catalog spli t mirror
BACKUP DATAFILECOPY command at th
e prompt:
RMAN> BACKUP DATAFILECOPY '/dk2/oradata/trgt/users01.dbf';
CHANGE ... UNCATALOG command to uncatalog the datafile copies you cataloged in step 6. For e
xample, enter:
RMAN> CHANGE DATAFILECOPY '/dk2/oradata/trgt/users01.dbf' UNCATALOG;
| See Also:
Oracle Database SQL Reference for |
Use the BACKUP BACKUPSET command to back up backup sets rather than database files. This command is especi
ally useful in the following scenarios:
To back up backup sets from disk to tape :
sbt channel, issue the BACKUP BACKUPSET command at the RMAN prompt. This example b
acks up all disk backup sets to tape:
RMAN> BACKUP DEVICE TYPE sbt BACKUPSET ALL;
This example backs up all disk backup sets to tape and then deletes the input disk backups:
RMAN> BACKUP DEVICE TYPE sbt BACKUPSET ALL DELETE INPUT;
LIST command to see a listin
g of backup sets and pieces.Use the
BACKUP COPY OF command to back up image copies of datafiles, control files, and archived logs.
The output of the BACKUP command can be either backup sets or image copies, so you can generate backup sets from your i
mage copies. This technique is useful when you want to back up a database backup on disk to tape, because all backups to tape must be
backup sets. You can use the MAXSETSIZE parameter of the BACKUP command to set a maximum size for each bac
kup set.
To back up image copies from disk to tape:
sb
t channel, issue the BACKUP COPY OF command at the RMAN prompt. This example backs up t
he latest image copy of the database to tape:
RMAN> BACKUP DEVICE TYPE sbt COPY OF DATABAS E;
This example backs up the latest image copy backup of a datab ase in backup sets on tape, and then deletes the input disk backups:
RMAN> BACKUP DEVIC E TYPE sbt COPY OF DATABASE DELETE INPUT;
LIST command to see a listing of backup sets and pieces.When backing up your image copies, identifying the image copy to back up is easier if you provide tags for your backups. Image copies of datafiles and archived redo logs have associated tags (if you do not provide one, one is automatically generated). The tag of an imag e copy is inherited by default when the image copy is backed up as a new image copy. You can also specify your own tag.
To take advantage of the tags associated with your image copy backups, use the WITH TAG sel
ector. As explained previously, the tag of the image copy being backed up will also be assigned to the new backup. When multiple imag
e copies have the same tag, the most recent image copy of a file with the specified tag will be backed up.
RMAN supports two distinct features by wh ich it can back up only those files that require backups: restartable backups and backup optimization.
With the restartable backup feature, RMAN bac
ks up only those files that were not backed up after a specified date. For example, by specifying the NOT BACKED
code> UP SINCE TIME clause, you can direct RMAN to back up only those files that were not back
ed up within the last day.
With backup optimization, the BACKUP command skips
the backup of a file if the identical file has already been backed up to the allocated device type. To override this behavior and bac
k up all files whether or not they have changed, specify the FORCE option on the BACKUP command. To enable
or disable backup optimization, specify ON or OFF on the CONFIGURE BACKUP O
PTIMIZATION command.
Additionally, BACKUP ... PLUS
code> ARCHIVELOG can archive unarchived online logs as well as back up archived logs.
|
a>See Also:
"Backup Optimization" for a conceptual overview of optimization, and "Restartable Backups" for a conceptual overview of restartable backups |
Fo
r backup optimization to be enabled, you must CONFIGURE BACKUP OPTIMIZATION to ON
. Backup optimization is OFF by default.
To use backup op timization with a backup operation:
CONFIGURE BACKUP OP
TIMIZATION command. For example, enter:
RMAN> CONFIGURE BACKUP OPTIMIZATION ON;
sbt device any archived redo logs that either have not been already backed up, or where the existin
g backups do not satisfy the current duplexing setting:
RMAN> BACKUP DEVICE TYPE sbt ARCHI VELOG ALL;
RMAN does not signal an error when it skips backing u p files due to backup optimization.
|
See Also:
"Backup Optimization" for a conceptual overview of optimization and backup retention policies |
Use the SINCE TIME parameter of the BACKUP command to specify a date after which a new backup is required. If you do not speci
fy the SINCE parameter, then RMAN only backs up files that have never been backed up.
To only back up files that were not backed up after a specified date:
Specify a valid date in the SINCE TIME parameter. For example, this command uses the defau
lt configured channel to back up all database files and archived redo logs that have not been backed up in the last two weeks:
RMAN> BACKUP NOT BACKED UP SINCE TIME 'SYSDATE-14' DATABASE PL US ARCHIVELOG;
You can
use the VALIDATE keyword of the BACKUP command to do the following:
RMAN do
es not actually produce backup sets, but rather reads the specified files in their entirety, to determine whether they can be backed
up and are not corrupted. In this sense, the BACKUP VALIDATE command is similar to the RESTORE
VALIDATE command, except for backups rather than restore jobs.
If the backup
validation discovers corrupt blocks, then RMAN updates the V$DATABASE_BLOCK_CORRUPTION view with rows describing the cor
ruptions. After a corrupt block is repaired, the row identifying this block is deleted from the view.
For example, you can validate that all database files and archived redo logs can be backed up by running a command as foll ows:
RMAN> BACKUP VALIDATE DATABASE ARCHIVELOG ALL;
This form of the command would check for physical corruption. To check for logical corruption,
RMAN> BACKUP VALIDATE CHECK LOGICAL DATABASE ARCHIVELOG ALL;
RMAN displays the same output that it would if it were really backing up the files. If RMAN cannot validate the backup of one or more of the files, then it displays an error message. For example, RMAN may show output similar to the following:
RMAN-00571: =========================================================== RMAN-005 69: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =================================== ======================== RMAN-03002: failure of backup command at 08/29/2001 14:33:47 ORA -19625: error identifying file /oracle/oradata/trgt/arch/archive1_6.dbf ORA-27037: unable to obtain file status SVR4 Error: 2: No such file or directory Additional information: 3
You cannot use the MAXCORRUPT or PROXY parameters with the <
code>VALIDATE option.
See Als
o:
|
This section contains these topics:
Assume that you configure an auto
matic sbt channel as follows:
RMAN> CONFIGURE DEVICE TYPE sbt PARALLELISM 1 ; # configure device RMAN> CONFIGURE CHANNEL DEVICE TYPE sbt PARMS='...'; # configure options for channels RMAN> CONFIGURE DEFAULT DEVICE TYPE to sbt; # set default device type
Assume that you want to back up the database to disk and use the default configured DISK
channel. You can specify that the BACKUP command should use a DISK channel as follows:
RMAN> BACKUP DEVICE TYPE DISK DATABASE;
To back up the database to the sbt device run this command:
RMAN> BACKUP D ATABASE;
The foll
owing example assumes that the database is running in ARCHIVELOG mode and that you have an automatic sbt ch
annel configured as follows:
RMAN> CONFIGURE DEVICE TYPE sbt PARALLELISM 1; RMAN> CONFIGURE DEFAULT DEVICE TYPE TO sbt; RMAN> CONFIGURE CHANNEL DEVICE TYPE sbt PARMS='ENV= (NSR_DATA_VOLUME_ POOL=BackupPool)';
To back up the database whil e skipping offline and read-only tablespaces, you can run the following command:
RMAN> B ACKUP DATABASE SKIP READONLY SKIP OFFLINE;
You need to back up a read-only tablespace only once after it has been made read-only. You can
use the SKIP READONLY option to skip read-only datafiles. If you use the SKIP OFFLINE option, then the BACKUP command does not attempt to access offline datafiles. Use this option if the offline datafi
les are not available.
Another way to persistently skip tablespaces across RMAN sessions is
to issue the CONFIGURE EXCLUDE command for each tablespace that you always want to skip. For example, you
may always want to skip the example tablespace, which has been made read-only. You can then issue:
< a name="1006559">RMAN> CONFIGURE EXCLUDE FOR TABLESPACE example;
Then, whenever you run BACKUP DATABASE, RMAN skips this tablespace. You do not have to specify a BACKUP command. You can override this behavior and include the example tablesp
ace as follows:
RMAN> BACKUP DATABASE NOEXCLUDE;
Assume that you back up the database and archived logs every night to tape by runnin g this command:
RMAN> BACKUP MAXSETSIZE 10G a> DATABASE PLUS ARCHIVELOG;
The preceding command sets an upper limit to the size of each backup set so that RMAN produces multiple backup sets. Assume that the media management device fails halfw ay through the backup and is then restarted. The next day you discover that only half the backup sets completed. In this case, you ca n run this command in the evening:
RMAN> BACKUP # Note that the NOT BACKED UP SINCE clause should be placed immediately after the BACKUP # keyword or after each individual backupSpec clause NOT BACKED UP SINCE TIME 'SYSDATE-1' MAXSETSIZE 10M DATABASE PLUS ARCHIVELOG;
RMAN backs up only files tha t were not backed up during in the previous 24 hours. When RMAN finds out that particular file is already backed up it displays outpu t similar to the following:
RMAN-06501: skipping datafile 1; already backed up on NOV 02 20 03 18:10:00 RMAN-06501: skipping datafile 2; already backed up on NOV 02 2003 18:09:45 RM AN-06501: skipping datafile 3; already backed up on NOV 02 2003 18:09:45
Typically, you do not need to specify a format when backing up to tape because
the default %U variable generates a unique filename for tape backups. When backing up to disk, however, you can specify
a format if you need to spread the backup across several drives for improved performance. In this case, allocate one DISK channel for each disk drive and specify the format string on the ALLOCATE CHANNEL command so that the fi
lenames are on different disks. For example, issue:
RUN { ALLOCATE CHANNEL disk1 DEVICE TYPE DISK FORMAT '/disk1/%d_backups/%U'; ALLOCATE CHANNEL disk2 D EVICE TYPE DISK FORMAT '/disk2/%d_backups/%U'; ALLOCATE CHANNEL disk3 DEVICE TYPE DISK FORMAT '/disk3/%d_back ups/%U'; BACKUP AS COPY DATABASE; }
You can accomplish the same result by configuring automatic channels as follows:
CONFIGURE DEVICE TYPE DISK PARALLELISM 3; CONFIGURE DEFAULT DEVICE TYPE TO DISK; CONFIGURE CHANNEL 1 DEVICE TYPE DISK FORMAT '/disk1/%d_backups/%U'; CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMA T '/disk2/%d_backups/%U'; CONFIGURE CHANNEL 3 DEVICE TYPE DISK FORMAT '/disk3/%d_backups/%U'; BACKUP AS COPY DATABASE;
If you specify a nonexistent direct ory, RMAN displays output such as the following:
RMAN-00571: ============================== ============================= RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03009: failure of bac kup command on ORA_DISK_1 channel at 08/29/2001 14:36:04 ORA-19504: failed t o create file "/nosuchdisk/0cd2momi_1_1" ORA-27040: skgfrcre: create error, unable to create file SVR4 Error: 2: No such file or directory
In this scenario, you have a 35 GB database that you want to back up to disk. Because RMAN can only write one backup piece on a raw disk device, you decide to spread the backup across four file systems. You decide to make each b ackup set roughly the same size: 10 GB. You want each backup piece to be no more than 2 GB so that each backup set contains up to fiv e backup pieces.
You decide to use the FORMAT parameter of the CONFIGURE
CHANNEL command so that each channel will write to a different file system. You use conversion variables to guar
antee unique names for the backup pieces. For example, the following commands configure four channels, configures their formats so th
at they write to the four file systems (/fs1, /fs2, /fs3, /fs4) and groups the da
tafiles so that each backup set is about the same size.
RMAN> CONFIGURE DEVICE TYPE DISK PARALLELISM 4; RMAN> CONFIGURE CHANNEL 1 DEVICE TYPE DISK FORMAT='/fs1/%U' MAXPIECESIZE 2G; RMAN> CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT='/fs2/%U' MAXPIECESIZE 2G; RMAN> CONFIGURE CHAN NEL 3 DEVICE TYPE DISK FORMAT='/fs3/%U' MAXPIECESIZE 2G; RMAN> CONFIGURE CHANNEL 4 DEVICE TYPE DISK FORMAT=' /fs4/%U' MAXPIECESIZE 2G; RMAN> CONFIGURE DEFAULT DEVICE TYPE TO DISK;
Then, you can run this command every night to generate four backup sets, each in a different directory and each approximately the same size:
RMAN> BACKUP AS BACKUPSET DATABASE;
You can also back up the backup sets from disk to four different tapes from a
tape pool by setting PARALLELISM=4 for the sbt device (and specifying the appropriate vendor-specific PARMS for the sbt channel), as in the following example:
RMAN> CONF IGURE DEVICE TYPE sbt PARALLELISM 4; RMAN> CONFIGURE CHANNEL DEVICE TYPE sbt PARMS='...'; RMAN> BACKUP DEVICE TYPE sbt BACKUPSET ALL DELETE INPUT;
N ote that this example makes certain assumptions, such as no datafile is too large to fit into a backup piece, that there are at least four datafiles in the database, and so on. In extrapolating from this example you must take into account the specifics of your own c ircumstances.
When making backups
, RMAN divides the total number of files requiring backups by the number of allocated channels to calculate the number of files to pl
ace in each backup set. Use the MAXSETSIZE parameter to override this calculation and specify how many files should go i
n each backup set.
The MAXSETSIZE parameter specifies a maximum size for a bac
kup set in units of bytes (default), kilobytes, megabytes, or gigabytes. Thus, to limit a backup set to 305 MB, specify MAXSETS
IZE=305M. RMAN attempts to limit all sets to this size.
You can use MAXSETSIZE
to limit the size of backup sets so that the database is divided among more than one backup set. If you configure MAXSE
TSIZE so that you generate multiple backup sets, however, then if the backup fails partway through, you can use the restartabl
e backup feature to back up only those files that were not backed up during the previous attempt. See
"Restartable Backups" for a conceptual overview of restartable backups.
The following example configures a tape device, then backs up archived redo logs to tape, limiting the size to 10 0 MB so that if the backup fails partway through, it can be restarted:
RMAN> CONFIGURE D EVICE TYPE sbt PARALLELISM 1; RMAN> CONFIGURE DEFAULT DEVICE TYPE TO sbt; RMAN> BAC KUP MAXSETSIZE = 100M ARCHIVELOG ALL;
This example accomplishes t
he same result with CONFIGURE MAXSETSIZE:
RMAN> CONFIGURE DEFA ULT DEVICE TYPE TO sbt; RMAN> CONFIGURE MAXSETSIZE = 100M; RMAN> BACKUP ARCHIVELOG ALL;
Note that if you specify a MAXSETSIZE value tha
t is too small to contain the biggest file that you are backing up (either the actual size of that file, or if binary compression is
specified, then the size of tha tfile after compression), then RMAN displays an error stack such as the following:
RMAN-00571: =========================================================== RMAN-00569: === ============ ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: ========================================== ================= RMAN-03002: failure of backup command at 11/03/03 14:40:33 RMAN-06182: archive log larger than MAXSETSIZE: thread 1 seq 1 /oracle/oradata/trgt/arch/archive1_1.dbf
Backup piece size is an issue in thos
e situations where it exceeds the maximum file size of the file system or media management software. Use the MAXPIECESIZE parameter of the CONFIGURE CHANNEL or ALLOCATE CHANNEL command to limit the siz
e of backup pieces.
For example, to limit the backup file size to 2GB or less, you can conf
igure the automatic DISK channel as follows and then run BACKUP DATABASE:
# max file size for backup pieces is 2GB RMAN> CONFIGURE CHANNEL DEVICE TYPE DISK MAXP IECESIZE 2GB; RMAN> BACKUP DATABASE;
Not
e that in version 2.0 of the media management API, media management vendors can specify the maximum size of a backup piece that can b
e written to their media manager. RMAN will respect this limit regardless of the settings you configure for MAXPIECESIZE
.
Assume that y ou set your initialization parameters so that you archive to the following local destinations:
LOG_ARCHIVE_DEST_1 = 'LOCATION=/disk1/arch/' LOG_ARCHIVE_DEST_2 = 'LOCATION=/disk2/arch/' LOG_ARCHIVE_DEST_3 = 'LOCATION=/disk3/arch/'
Each directory
contains the same set of logs, starting with log sequence 1 and ending at log sequence 400. Unknown to you, a user inadvertently dele
tes logs 300 through 400 from /disk1/arch and logs 350 through 400 from /disk2/arch. You run this backup co
mmand:
RMAN> BACKUP ARCHIVELOG FROM SEQUENCE 288 UNTIL SEQUENCE 388 THREAD 1 DELETE INPUT;
RMAN begins backing up logs starting with log sequence 288. If the copy of log 300 that was deleted from /disk1/arc
h is the one that RMAN attempts to back up, then RMAN checks the repository to determine whether other copies of this log sequ
ence exist, and backs up the log in either /disk2/arch or /disk3/arch. Hence, because a copy of each log in
sequence 288 through 388 is located in at least one of the three directories, RMAN can back up all the specified logs.
Assume that you back
up database trgt while it is open. You want to back up only those archived redo logs required to recover this online bac
kup.
The recommended solution to this problem is to add the PLUS ARCHIVELOG cl
ause to your database backup command, as shown here:
RMAN> BACKUP DATABASE PLUS ARCHIVEL OG;
See Oracle Database Backup and Recovery Basics and Oracle Database Recovery Manager Reference for details on using B
ACKUP... PLUS ARCHIVELOG.
Prior to Oracle Database Release 10g , however, you could manually determine which archived logs are required and back them up, using the following procedure.
To determine the archived logs needed for recovery of an online backup:
SQL> ALTER SYSTEM ARCHIVE LOG CURRENT; < /a>
V$LOG to determine the log sequence numb
er of the current redo log, as in the following example (which includes output):
SQL> SELE CT SEQUENCE# FROM V$LOG WHERE STATUS = 'CURRENT'; SEQUENCE# ----- ----- 9100
RMAN> BACKUP DATA BASE;
RMAN> SQL 'ALTER SYSTEM ARCHIVE LOG CURRENT';
V$LOG to determine the log seq
uence number of the current redo log:
SQL> SELECT SEQUENCE# FROM V$LOG WHERE STATUS = 'CUR RENT'; SEQUENCE# ---------- 9112
For example, issue the following to back up the necessary archived logs:
RMAN> BACKUP ARCHIVELOG FROM SEQUENCE 9100 UNTIL SEQUENCE 9111;
In this scenario, you set in
itialization parameters so that you automatically archive redo logs to two directories: ?/oradata/trgt/arch/dest_1 and <
code>?/oradata/trgt/arch/dest_2. Therefore, you have two identical copies of the archived redo log for each log sequence numbe
r. You decide to back up each copy of the archived redo logs and then delete the originals. (Note that the degree of backup duplexing
configured or specified in the BACKUP command determines the number of output files, independent of the number of input
files. See "Duplexing Backup Sets" for details.)
The easiest solution in this case is to use the DELETE ALL INPUT
option means that RMAN deletes all logs that match the ARCHIVELOG criteria. Hence, it can remove all logs from both ?/oradata/trgt/arch/dest_2.
For exampl e, run the following command to back up all logs that could be used to recover from a point 10 days ago, and then delete all logs wit hin the specified time range from disk:
RMAN> BACKUP DEVICE TYPE sbt < /a> ARCHIVELOG ALL FROM TIME 'SYSDATE-10' DELETE ALL INPUT;
A differential incremental backup contains only blocks that have been changed since the most recent backup at the same level or lower. The first incremental backup must be a level 0 backup that contains all used blocks. The following is a level 0 base backup:
RMAN> BACKUP INCREMENTAL LEVEL 0 DATABASE;
An incremental backup at level 1 will contain all bl ocks changed since the most recent level 1 backup. If no previous level 1 backup is available, then RMAN copies all blocks changed si nce the base level 0 backup. The following is a level 1 backup of the database:
RMAN> BA CKUP INCREMENTAL LEVEL 1 DATABASE;
You can perform incremental ba
ckups in NOARCHIVELOG mode, but the backups must be consistent. Hence, you cannot take online incremental backups.
A cumulative incremental backup at level 1 contains only blocks that have been changed since the most recent backup at level 0. Cumulative backups require more stor age space than differential backups, but they are preferable during a restore operation because only one backup for a given level is needed. Note that the first incremental backup must be a level 0 backup that contains all used blocks.
In contrast to a cumulative backup, a differential backup at level 1 will determine which level 0 or em> level 1 backup occurred most recently and copy all blocks changed since this backup.
BA CKUP INCREMENTAL LEVEL 1 CUMULATIVE DATABASE; # blocks changed since level 0
When you create multiple backup sets and allocate multiple channels , RMAN automatically writes multiple backup sets in parallel. The allocated server sessions share the work of backing up the specifie d datafiles, control files, and archived redo logs. Note that you cannot stripe a single backup set across multiple channels.
RMAN automatically assigns a backup set to a device. You can use the CHANNEL paramete
r so that RMAN writes all backup sets for a backupSpec to a specific channel.
For example, this example parallelizes the backup operation by specifying which channels RMAN should back up to disk and whi
ch to sbt:
RMAN> RUN { ALLOCA TE CHANNEL ch1 DEVICE TYPE DISK FORMAT = '/backup/df/%U'; ALLOCATE CHANNEL ch2 DEVICE TYPE DISK FORMAT = '/ba ckup/cf/%U'; ALLOCATE CHANNEL ch3 DEVICE TYPE sbt; BACKUP AS BACKUPSET # all output f iles are in backup sets # channel ch1 backs up datafiles to /backup/df directory DATAFILE 1,2,3,4 CHANNEL ch1 # channel ch2 backs up control file copy to /backup /cf directory CONTROLFILECOPY '/tmp/control01.ctl' CHANNEL ch2; BACKUP AS BACKUPSET # channel ch3 backs up archived redo logs to tape ARC HIVELOG FROM TIME 'SYSDATE-14' CHANNEL ch3; }
You cannot back up to DISK and sbt at the same time using automatic channels:
you must manually allocate them.
Thi s script puts the database into the correct mode for a consistent, whole database backup and then backs up the database. The script p erforms a shutdown, startup, shutdown, and then startup again before creating multiple copies of the backup:
# Shut down database cleanly with immediate option. This type of shutdown lets # current ca lls to the database complete, but prevents further logons or calls. # If the database is not up, you receive a message saying so but RMAN will not # treat this situation as an error. SHUTDOWN IMMEDI ATE; # Start up the database in case it suffered instance failure or was # closed with SHUTDOWN ABORT before starting this script. # The script performs instance recovery i f # needed. Oracle uses the default init.ora file. Alternatively, use this form: # START UP FORCE DBA pfile=filename. # Use the DBA option because you are going to shut down again # and do not want to let users in during the short interval. Use the FORCE # option because it can not hurt and might help in certain situations. STARTUP FORCE DBA; SHUTDOWN IMMEDIATE; # The database is cleanly closed and ready for a consistent backup. RMAN # requires that the database be started and mounted to perform a backup. RMAN> STARTUP MOUNT; # this example uses automatic channels to make the backup BACKUP COPIES 2 INCREMENTAL LEVEL 0 MAXSETSIZE 10M < /a> DATABASE; # Now that the backup is complete, open the database. ALTER DATABASE OPEN;
You can skip tablespaces, but any skipp ed tablespace that has not been offline or read-only since its last backup will be lost if the database has to be restored from a bac kup. When backing up to disk, make sure that the destination file system has enough free space.
You can use operating system utilities to make copies of datafile s and then catalog them in the recovery catalog.
If the database is open and the datafile i
s online, then issue ALTER TABLESPACE ... BEGIN BACKUP to put the da
tafile in backup mode. (If you will be copying all datafiles, you can use ALTER DATABASE BEGIN BACKUP to put all tablesp
aces in backup mode, instead of issuing individual commands for each tablespace.) Then copy the files using native operating system c
ommands. Once the copy is completed, use ALTER TABLESPACE... END BACKUP to take the datafile out of backup
mode (or use ALTER DATABASE END BACKUP to take all tablespaces in backup mode out of backup mode). Finally, catalog the
resulting datafile copy using the RMAN CATALOG DATAFILECOPY command.
For examp le, if you created a copy of your datafile /oracle/oradata/users01.dbf into file /tmp/users01.dbf, this command will add /tmp/users01 .dbf to the catalog:
CATALOG DATAFILECOPY '/tmp/users01.dbf';
If you try to catalog a datafile copy from a database other than the connected target database , then RMAN issues an error such as the following:
RMAN-00571: ============================ =============================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03009: failure of c atalog command on default channel at 08/29/2001 14:44:34 ORA-19563: datafile copy header validation failed for file /tmp/tools01.dbf
If you configure a retention policy, then you may want to exclude specified backups from this policy. For example, you may want to archive a consiste nt backup of the database once a year to serve as a historical record. This long-term backups does not function as a backup that you may perform recovery on, but an archived snapshot of data at a particular time.
To exempt a
backup from the retention policy, specify the KEEP option on the BACKUP command. You can also specify NOLOGS to indicate whether RMAN should save archived logs for possible recovery of this backup. If you
specify NOLOGS, then the backup must be consistent.
This example keeps the bac kup of the database indefinitely and does not save archived logs needed to recover it:
RMAN > SHUTDOWN IMMEDIATE; RMAN> STARTUP MOUNT; # put database in consistent state RMAN > BACKUP DATABASE KEEP FOREVER NOLOGS TAG 'db_archive_1'; # make long-term consistent backup # mark backup as unavailable in the repository so that RMAN does not attempt to # restore it unless explicitly specified on the RESTORE command RMAN> CHANGE BACKUP TAG 'db_ar chive_1' UNAVAILABLE; RMAN> SQL 'ALTER DATABASE OPEN';
Run the CONFIGURE BACKUP OPTIMIZATION command to enable bac
kup optimization. When specific conditions are met (described in "Backup Optimization Algorithm"), RMAN skips backups of files that are identical to files that are already backed up.
Assume that you configure optimization and a retention policy as follows:
CONFIGURE DEFAULT DEVICE TYPE TO sbt; CONFIGURE BACKUP OPTIMIZATION ON; CONFI GURE RETENTION POLICY TO RECOVERY WINDOW OF 4 DAYS;
Then, you run this command every night to back up the database to tape:
BAC KUP DATABASE;
Because backup optimization is configured, RMAN ski
ps backups of offline and read-only datafiles only if the most recent backups were made on or after the earliest point in the recover
y window. RMAN does not skip backups when the most recent backups are older than the window. For example, optimization ensures you do
not end up with a new backup of the read-only datafile ?/oradata/trgt/history01.dbf every night, so long as one backup
set containing this file exists within the recovery window.
For example, if the most recent backup of the datafiles was on Sunday, and the point of recoverability (that is, the earliest date in the recovery window) is on Sat urday, then RMAN skips the datafiles when you run the Wednesday backup. On Friday, the point of recoverability is now Monday, so the Sunday backup is now outside the window. Hence, the Friday backup does not skip the datafiles.
Assume that you want to back up all the archived l
ogs every night. However, you do not want to have multiple copies of each log sequence number. So, you configure backup optimization
to ON, then run this command in a script every night at 1 a.m.:
BACKUP DEVICE TYPE sbt ARCHIVELOG ALL;
RMAN skips all logs except those produce d in the last 24 hours. In this way, you keep only one copy of each archived log on tape.
In this example, you back up logs that are not already on tape to one tape pool, then back up the same logs to a second tape pool. Finally, you delete old logs.
For the first step, perform the one-time configuration:
# configure backup optimization CONFIGURE BACKUP OPTIMIZATION ON; CONFIGURE DEFAULT DEVICE TYPE TO sbt;
Then, run the following script at the same time every night to back u p the logs generated during the previous day to two separate tape pools:
# The following co mmand backs up just the logs that are not on tape. The # first copies are saved to the tapes from the pool "ar chivelog_pool_1" RUN { ALLOCATE CHANNEL c1 DEVICE TYPE sbt PARMS='NSR_DATA_VOLUME_POOL=ARCHIVELOG_POOL_1'; BACKUP ARCHIVELOG ALL; } # Make one more copy of the archived logs and save them to tapes from a # differen t pool RUN { ALLOCATE CHANNEL c2 DEVICE TYPE sbt PARMS='NSR_DATA_VOLUME_POOL=ARCHIVELOG_POOL_2'; BACKUP ARCHIVELOG FROM TIME 'SYSDATE-1' UNTIL TIME 'SYSDATE'; # specify UNTIL so RMAN does not archive current log } # Delete old logs - for example, delete logs created within the last week. DELE TE ARCHIVELOG ALL COMPLETED AFTER 'SYSDATE-7';
Assume a more sophisticated scenario in which your goal is to back up the archived logs to tape eve ry day. However, you are worried about tape failure, so you want to ensure that you have more than copy of each log sequence number o n an separate tape before you perform your weekly deletion of logs from disk.
First, perfor m a one-time configuration:
# configure backup optimization CONFIGURE BACKUP OPTIMIZATION ON; CONFIGURE DEVICE TYPE sbt PARALLELISM 1; CONFIGURE default DEVIC E TYPE TO sbt; # configure a default channel that sends backups to tape pool "first_copy" CONFIGURE CHANNEL DEVICE TYPE sbt PARMS='ENV=(NSR_DATA_VOLUME_POOL=first_copy);
Because you have optimization enabled, you can run the following command every evening to back up all archived logs t o the "first_copy" pool that have not already been backed up:
BACKUP ARCHIVELOG ALL TAG fir st_copy;
Every Friday evening you create an additional backup of all archived logs in a different tape pool. Also, at the end of the backup, you want to delete all archived logs that already have at least two copies on tape. So you run the following script:
RUN { # 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" ALLOCATE CHANNEL c1 DEVICE TYPE sbt PARMS='ENV=(NSR_DATA_VOLUME_POOL=second_copy)'; ALLOCATE CHANNEL c2 DEVICE TYPE sbt PARMS='ENV=(NSR_DATA_VOLUME_POOL=first_copy)'; BACKUP CHANNEL C1 ARCHIVELOG UNTIL TIME 'SYSDATE ' NOT BACKED UP 2 TIMES # back up only logs without 2 backups on tape TAG SECOND _COPY; BACKUP CHANNEL C2 ARCHIVELOG UNTIL TIME 'SYSDATE' NOT BACKED UP 2 TIMES # back up only logs without 2 backups on tape TAG FIRST_COPY; } # now delete from disk all logs that have been backed up to tape at least twice DELETE AR CHIVELOG ALL BACKED UP 2 TIMES TO DEVICE TYPE sbt;
The Friday script creates a second copy of all archived logs in the "second_copy" tape pool. After the backup, you can send the tape from the pool "second_copy" to secure storage. You should use this tape backup only if the primary tape from pool "first_co py" is damaged. Because the secondary tape is in a secure place, you do not want RMAN to use it for recovery, so you can mark the bac kup as unavailable:
CHANGE BACKUP OF ARCHIVELOG TAG SECOND_COPY UNAVAILABLE;
By default a checksum is calculated for every bl
ock read from a datafile and stored in the backup or image copy. If you use the NOCHECKSUM option, then checksums are no
t calculated. If the block already contains a checksum, however, then the checksum is validated and stored in the backup. If the vali
dation fails, then the block is marked corrupt in the backup.
The SET MA
XCORRUPT FOR DATAFILE command sets how many corrupt blocks in a datafile that BACKUP wi
ll tolerate. If a datafile has more corrupt blocks than specified by the MAXCORRUPT parameter, the command terminates. I
f you specify the CHECK LOGICAL option, RMAN checks for logical and physical corruption.
By default, the BACKUP command terminates when it cannot access a datafile. You can specify para
meters to prevent termination, as listed in the following table.
| a> Then RMAN skips... | |
|---|---|
|
|
Inaccessible datafiles. A datafile is only considered inaccessible if it cannot be read. Some offline datafiles can still be read because they exist on disk. Others have been deleted or moved and so cannot be read, making them inaccessible. |
|
|
Offline datafiles. |
|
|
Datafiles in r ead-only tablespaces. |
The following example uses an automatic cha
nnel to back up the database, and sets the corruption level for the datafile in the SYSTEM tablespace so that up to 10 e
rrors will be accepted:
RMAN> RUN { SET MA XCORRUPT FOR DATAFILE 1 TO 10; BACKUP DATABASE SKIP INACCESSIBLE SKIP READONLY SKIP OFFLINE; }