|Oracle® Database Backup and Recovery Advanced User's Guide
10g Release 2 (10.2)
Part Number B14191-02
Several RMAN commands can cause the deletion of backups or archived logs, either directly or as a consequence of a backup of those files.
This section contains the following topics:
Table 9-1 describes the functionality of the various RMAN commands that can cause backups to be deleted.
Table 9-1 Maintenance Commands and Scripts
|Command or Script||Purpose|
To delete backups, update the control file records to status
You can specify that
To back up archived logs, datafile copies, or backup sets, then delete the input files from the operating system after the successful completion of the backup. RMAN also deletes and updates repository records for the deleted input files.
If you specify
To delete recovery catalog records for specified backups and change their control file records to status
See Also:"Crosschecks of RMAN Backups"
DELETE command can remove any file that the
CROSSCHECK commands can operate on. For example, you can delete backup sets, archived redo logs, and datafile copies. The
DELETE command removes both the physical file and the catalog record for the file.
DELETE command within RMAN to remove RMAN backups, rather than an operating system or media manager utility or command. Otherwise, the RMAN repository can contain records of backups that are no longer available for use in restore operations.
If you delete backups without using RMAN, you can use one of the following methods within RMAN to update the RMAN repository directly without performing a crosscheck:
CROSSCHECK to change the status of these files to
EXPIRED and then run
EXPIRED to delete the records from the RMAN repository
UNCATALOG to remove the catalog records
If you have configured a retention policy, then you can run
OBSOLETE periodically to delete all backups considered obsolete by this policy. For example, you can run
OBSOLETE in a script every night with a scheduling utility, freeing disk and tape space used by backups that are no longer needed.
Note that using a flash recovery area as the destination for all backups eliminates the need to manage obsolete backups. Obsolete backups will be deleted from the flash recovery area automatically as disk space is needed to store backup-related files.
See Also:"Reports of Obsolete Backups"
CROSSCHECK command updates the repository status for a backup to
EXPIRED when it cannot locate it at the location to which it was backed up. This condition could occur if, for example, a backup was deleted from disk at the operating system level. You can identify expired backups by running the
CROSSCHECK command as in the following example:
RMAN> CROSSCHECK BACKUP; crosschecked backup piece: found to be 'AVAILABLE' backup piece handle=0ad8d32i_1_1 recid=10 stamp=445025363 crosschecked backup piece: found to be 'AVAILABLE' backup piece handle=c-1334876723-20011105-00 recid=11 stamp=445025367 crosschecked backup piece: found to be 'EXPIRED' backup piece handle=0cd8d361_1_1 recid=12 stamp=445025473 crosschecked backup piece: found to be 'AVAILABLE' backup piece handle=c-1334876723-20011105-01 recid=13 stamp=445025475 Crosschecked 4 objects
If you run
CROSSCHECK while some backup device is temporarily not accessible, this can mark backups as expired when in fact they are still present on the backup device, and are available again once the device is accessible. For example, this can happen if a disk is unmounted or if RMAN does not correctly connect to a media manager. In such a case, fix the problem that prevented RMAN from finding the backups and rerun
EXPIRED command removes the record of expired backups from the RMAN repository, by actually deleting the recovery catalog records for expired backups, and updates their control file records to status
This command is especially useful if a user inadvertently deletes RMAN backups or archived logs from disk with an operating system utility. In such a case, the RMAN repository is not synchronized with the actual contents of disk. By running the
CROSSCHECK command, RMAN marks the backups that it cannot find as expired. Then, you can run
EXPIRED to remove the records for these files.
You may want to delete files such as archived logs only if they have been backed up a specified number of times to tape. The
DELETE command supports this behavior. The following example deletes all archived redo logs that have already been backed up at least two times to tape:
RMAN> DELETE ARCHIVELOG ALL BACKED UP 2 TIMES TO DEVICE TYPE sbt;
INPUT command can delete archived redo logs, datafile copies, and backup sets after backing them up. This functionality is especially useful when backing up archived logs on disk to tape. RMAN backs up one copy of each log sequence number, and then deletes the file that it backs up. For example, assume that you issue:
RMAN> BACKUP ARCHIVELOG ALL DELETE INPUT;
In this command, RMAN backs up one copy of each log for each available sequence number, and then deletes only the archived redo log file that it actually backs up. If you have multiple redo log archiving destinations, the other copies of the same log sequence number are not deleted.
If you specify the
INPUT option, then RMAN deletes whichever files match the criteria that you specify, even if there are several files of the same log sequence number in different archiving destinations. For example, assume that you archive to three different directories. Then, you issue this command:
RMAN> BACKUP ARCHIVELOG ALL FROM SEQUENCE 1200 DELETE ALL INPUT;
In this case, RMAN backs up only one copy of each log sequence between 1200 and the most recent sequence, but deletes all logs with these sequence numbers from all three archive destinations.
Note:If you want to delete only a subset of the logs being backed up, you can use
INPUTclause, and then use a separate
DELETEcommand with a
In particular, in a Data Guard environment, it is not recommended to use BACKUP... DELETE INPUT to delete archived logs, as RMAN cannot delete the logs generated on another node. A separate
DELETE command with a
SBT command provides more direct control over deleting logs in this environment.
See Also:Oracle Database Backup and Recovery Reference for
During backup of archived redo logs, RMAN checks the file being backed up for corruption. If corruption is found, RMAN automatically switches to reading another copy of the same archived redo log, if one exists. For example, assume that
/log2 are the only enabled archiving destinations, and that they contain logs with sequence number up through 150. You run this command:
RMAN> BACKUP ARCHIVELOG FROM SEQUENCE 123 DELETE ALL INPUT;
RMAN can start reading from any copy of a given log, and switch to reading a different copy if it is unable to read the first copy in its entirety. For example, if RMAN starts reading the copy of log sequence 123 from
/log1 and discovers corruption in the file, it continues reading from the copy in
INPUT is specified, RMAN deletes all copies of logs on disk of sequence 123 and higher.
Every RMAN backup produces a corresponding record in the RMAN repository. This record is stored in the control file. If a recovery catalog is used, the record can also be found in the recovery catalog after the recovery catalog is resynced from the control file.
For example, if you generate a full database backup set, then you can view the record for this backup set in the
V$BACKUP_SET control file view. If you use a recovery catalog, then you can also access the record in the
RC_BACKUP_SET catalog view.
V$ control file views and recovery catalog tables differ in the way that they store information, and this affects how RMAN handles repository records. The recovery catalog RMAN repository is stored in actual database tables, while the control file version of the repository is stored in an internal structure in the control file.
When you use an RMAN command to delete a backup, RMAN performs the following steps:
Removes the physical file from the operating system (if the file is still present)
Updates the backup records in the control file to status
Removes the backup records from the recovery catalog tables (if RMAN is connected to a recovery catalog)
Because of the way that control file data is stored, RMAN cannot remove the record from the control file, only update it to
DELETED status. However, because the catalog tables are ordinary database tables, RMAN removes rows from them in the same way that rows are deleted from any table.
The RMAN repository record for an object can sometimes fail to reflect the physical status of the object. For example, you backup an archived redo log to disk and then use an operating system utility to delete the object. If you do not run the
CROSSCHECK command to update the repository, and if you then run
DELETE against the object, then the repository shows that the object is
AVAILABLE while the object is in fact missing. The following table indicates the behavior of
DELETE in such situations.
|Repository Status||Physical Status||Behavior of DELETE Command|
||Not found on media||Does not delete the object and reports the list of mismatched objects at the end of the job. RMAN does not update the repository status.|
||Found on media||Does not delete the object and reports the list of mismatched objects at the end of the job. RMAN does not update the repository status.|
||Any||Removes repository record and deletes object if it exists. All I/O errors are ignored.|
If you use the
FORCE option of
DELETE, RMAN will remove the repository record and delete the file if it exists. All I/O errors are ignored, and RMAN displays the number of objects deleted at the end of the job.