Rman Qusans
Rman Qusans
Rman Qusans
RMAN RMAN becomes more powerful with a redesigned incremental backup scheme, offline recovery of incremental backups, previewing restore, recovering through reset logs, file compression, and much more Most people would agree that RMAN is the de facto tool of choice for Oracle database backup. But as powerful as they were, early versions of RMAN left something to be desired. Like many DBAs, I had pet peeves about the absence of what I consider to be must-have features. Fortunately, Oracle Database 10g addresses many of these issues by incorporating many desirable features, making RMAN an even more powerful and useful tool. Let's take a look. Incremental Backups Revisited RMAN includes an option for incremental backups. But truthfully, how often do you use it? Probably occasionally, or possibly even never. This option instructs the tool to back up blocks that have changed since the last incremental backup at the same level or below. For instance, a full backup (level_0) is taken on day 1 and two incrementals of level_1 are taken on days 2 and 3. The latter two merely back up the changed blocks between days 1 and 2 and days 2 and 3, not across the entire backup time. This strategy reduces backup size, requiring less space, and narrows the backup window, reducing the amount of data moving across the network. The most important reason for doing incremental backups is associated with data warehouse environments, where many operations are done in NOLOGGING mode and data changes do not go to the archived log fileshence, no media recovery is possible. Considering the massive size of data warehouses today, and the fact that most of the data in them does not change, full backups are neither desirable nor practical. Rather, doing incremental backups in RMAN is an ideal alternative. So why do many DBAs do incremental backups only rarely? One reason is that in Oracle9i and below, RMAN scans all the data blocks to identify candidates for backup. This process puts so much stress on the system that doing incrementals becomes impractical. Oracle Database 10g RMAN implements incremental backups in a manner that disposes of that objection. It uses a file, analogous to journals in filesystems, to track the blocks that have changed since the last backup. RMAN reads this file to determine which blocks are to be backed up. You can enable this tracking mechanism by issuing the following command: SQL> alter database enable block change tracking using file '/rman_bkups/change.log'; This command creates a binary file called /rman_bkups/change.log for tracking purposes. Conversely, you can disable tracking with SQL> alter database disable block change tracking; To see whether change tracking is currently enabled, you can query:
RMAN> backup incremental level_1 for recover of copy with tag level_0 database; Here we have instructed RMAN to make an incremental level_1 backup and merge that with the full backup copy with the tag level_0. After this command, level_0 becomes a full backup of that day. So, on Tuesday, the backup with tag level_0, when merged with incremental level_1 backup, becomes identical to the full Tuesday backup. Similarly, the incremental taken on Saturday, when applied to the backup on disk, will be equivalent to a full level_0 Saturday backup. If the database fails on Saturday, you just need to restore the level_0 backup plus a few archive logs to bring the database into a consistent state; there is no need to apply additional incrementals. This approach cuts down recovery time dramatically, speeds backup, and eliminates the need to make a full database backup again. Compressed Files With disk-based backups in the flash recovery area, you still have a big limitation: disk space. Especially when going across a networkas is usually the caseit's advisable to create as small a backup set as possible. In Oracle Database 10g RMAN, you can compress files inside the backup command itself: RMAN> backup as compressed backupset incremental level 1 database; Note the use of the clause COMPRESSED. It compresses backup files with an important difference: while restoring, RMAN can read the files without uncompressing. To confirm compression, check for the following message in the output: channel ORA_DISK_1: starting compressed incremental level 1 datafile backupset Furthermore, you can verify that the backup was compressed by checking the RMAN list output: RMAN> list output; BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ --------------3 Incr 1 2M DISK 00:00:00 26-FEB-04 BP Key: 3 Status: AVAILABLE Compressed: YES Tag: TAG20040226T100154 Piece Name: /ora_flash_area/SMILEY10/backupset/2004_02_26/o1_mf_ncsn1_TAG20040226T100154_0 3w2m3lr_.bkp Controlfile Included: Ckp SCN: 318556 Ckp time: 26-FEB-04 SPFILE Included: Modification time: 26-FEB-04 As with any compression process, this approach puts pressure on CPUs. As a tradeoff, you can keep more RMAN backups on disk that are readily available for restore-and-recover operations. Alternatively, you can make RMAN backups at the Physical Standby Database that can be used to recover the primary database. That approach will offload backup resourses to another host. Look Before You Leap: Recovery Preview In Oracle Database 10g, RMAN has gone one more step ahead by providing the ability to preview the backups required to perform a restore operation.
RMAN> restore database preview; Listing 1 shows the output of this operation. You can also preview specific restore operations; for example: restore tablespace users preview; Preview allows you to ensure the recovery readiness of your backup infrastructure by making periodic and regular checks. Resetlogs and Recovery Let's imagine that you have lost the current online redo log files and you have to perform an incomplete database recoverya rare but not unheard of situation. The biggest problem is resetlogs; after incomplete recovery you must open the database with the resetlogs clause, which sets the sequence number of the log threads to 1, making your earlier backups obsolete in RMAN and making the recovery operation more of a challenge. In Oracle9i and below, if you need to restore the database to a version prior to resetlogs, you have to restore to a different incarnation. In Oracle Database 10g, you don't have to do that. Thanks to additional infrastructure in the control file, RMAN can now readily use all backups, before and after a resetlogs operation, to recover the Oracle database. There is no need to shut down the database to make a backup. This new capability means that the database can be re-opened immediately for the user community after a resetlogs operation. Ready for RMAN The enhancements in Oracle Database 10g RMAN make it an even more compelling tool in your backup strategy. The improvements to the incremental backup process alone make RMAN tough to ignore.
SPFILE. (Datafiles and archivelogs cannot be mixed together in the same backup set.) You can also back up existing backup sets into another backup set. Only RMAN can create or restore from backup sets.When multiple files are backed up into the same backup set, they are read concurrently and their data is multiplexed together. A backup set consists of one or more files called backup pieces, files in an RMAN-specific format. By default, a backup set consists of one backup piece. For example, you can back up ten datafiles into a single backup set containing a single backup piece (that is, one backup piece will be produced as output, and the backup piece and the backup set that contains it will be recorded in the RMAN repository). A file cannot be split across backup sets. Backup sets are the only type of backup that RMAN supports on media manager devices such as tapes. Backup sets can also be created on disk. RMAN defaults to creating backups as backup sets on both disk and tape.
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. SKIP OFFLINE
Offline datafiles.
SKIP READONLY
Datafiles in read-only tablespaces. The following example uses an automatic channel to back up the database, and sets the corruption level for the datafile in the SYSTEM tablespace so that up to 10 errors will be accepted: RMAN> RUN { SET MAXCORRUPT FOR DATAFILE 1 TO 10; BACKUP DATABASE SKIP INACCESSIBLE SKIP READONLY SKIP OFFLINE; }
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-00569: =============== 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 VALIDATE option.
what command do you execute to ensure that the control file is automatically backed up using Recovery Manager (RMAN)?
what command do you execute to ensure that the control file is automatically backed up using Recovery Manager? The automatic backup of the control file occurs independently of any backup of the current control file explicitly requested as part of your backup command. You can turn the autobackup feature on or off by running the following commands: CONFIGURE CONTROLFILE AUTOBACKUP ON; CONFIGURE CONTROLFILE AUTOBACKUP OFF;
Oracle 10g includes additional V$ views making the reporting of backup operations more transparent. * V$RMAN_OUTPUT - This is an in-memory view of the messages reported by RMAN holding a maximum of 32767 rows. Since this information is not recorded in the controlfile it is lost on instance restart. * V$RMAN_STATUS - This view displays progress and status information for in-progress and complete RMAN jobs. The information for the in-progress jobs is memory only, while the complete job information comes from the controlfile. * V$BACKUP_FILES - This view display information about RMAN image copies, backupsets and archived logs, similar to the information listed by the RMAN commands LIST BACKUP and LIST COPY. This view relies on the DBMS_RCVMAN.SETDATABASE procedure being run to set the database. The V$RMAN_CONFIGURATION view from Oracle 9i is still available in Oracle 10g.
Oracle Secure Backup provides key benefits: Fastest Oracle database backup to tape Single technical resource for entire backup environment Dynamic tape drive sharing between NAS / UNIX / Linux / Windows servers Policy-based backup management: o Backup encryption o Vaulting (rotation of tapes between multiple locations) o Tape duplication o Migration from virtual tapes to physical tapes Is Oracle Secure Backup a separate product from the Oracle database? Yes. Oracle Secure Backup is a separate product with independent release schedule and versioning from that of the database. What Oracle database versions does Oracle Secure Backup 10.2 support? Oracle Secure Backup 10.2 is tightly integrated with Recovery Manager (RMAN) supporting Oracle9i to Oracle Database 11g.
What is Oracle Secure Backup Express (OSB-XE)? Bundled with the Oracle database, Oracle Secure Backup Express is free and provides single-server tape backup management for one database server directly attached to one tape drive. Oracle Secure Backup documentation is applicable for OSB-XE with the exception of advanced functionality only available with the OSB edition. You can leverage advanced media management features by upgrading OSB-XE licensing to OSB edition. Please refer to the OSB 10.2 Licensing Documentation for feature restrictions in OSB-XE. How difficult is upgrading from OSB 10.1 to OSB 10.2? Upgrading from OSB 10.1 to 10.2 is relatively easy. The backup catalog is retained (unless explicitly deleted by user) during the upgrade maintaining all backup metadata and backwards compatibility of tapes (tapes written using OSB 10.1 are fully compatible with OSB 10.2 environments). Where can I find compatibility matrixes for Oracle Secure Backup? Platform, Web browser and NAS support is listed on Certify at metaling.oracle.com Tape device matrix is available at otn.oracle.com/technology/products/securebackup/tape_devices.pdf If a tape device is not listed on the compatibility matrix, does OSB support it? No. A tape device must be listed on the compatibility matrix to be supported. To request support for a tape device, log a Service Request (SR) through Oracle support requesting an enhancement request be filed on your behalf. Which network protocols does Oracle Secure Backup support? Oracle Secure Backup leverages NDMP for data transport over TCP/IP supporting backup, restore and other file access through NFSA and CIFS; host name resolution through NIS and DNS. How does backup encryption differ between Oracle Secure Backup 10.1 and 10.2? Oracle Secure Backup 10.2 provides backup encryption for file systems and Oracle9i forward. In OSB 10.2, policy based encryption is available at the global, server or backup job level.
Encryption keys may be generated transparently (randomly) or with a user-defined passphrase. In OSB 10.1, backup encryption to tape leveraged RMAN backup encryption only. What is the difference between RMAN backup encryption and OSB 10.2 database backup encryption? While both RMAN and Oracle Secure Backup 10.2 backup encryption leverage the same underlying Oracle encryption library, RMAN backup encryption is performed within the database and Oracle Secure Backup encryption occurs on the database server (outside of database). OSB 10.2 backup encryption supports Oracle9i forward while RMAN backup encryption is supports Oracle Database 10gR2 forward. Encryption key management differs as following: Oracle Secure Backup encryption keys are managed by OSB and stored on the OSB Administrative Server RMAN backup encryption keys are managed by the Oracle database Does Oracle Secure Backup support disk-based backups? No. However, Oracle Secure Backup supports virtual tape libraries (VTL). VTLs are disk appliances, which emulated tape drives and libraries. Oracle databases have always supported disk-based backups via RMAN. With Oracle Database 10g, the Flash Recovery Area was introduced to manage Oracle recovery related files. The Flash Recovery may be backed up to tape using Oracle Secure Backup. More information on the Flash Recovery Area is here. Does OSB vaulting support Iron Mountain FTP format? Yes. Oracle Secure Backup vaulting reports may be generated in Iron Mountain FTP format. Is Oracle Secure Backup integrated with 3rd-party backup tools such as Veritas NetBackup or Tivoli Storage Manager? No, Oracle Secure Backup is not integrated with any 3rd-party backup tools. Oracle Secure Backup is an alternative to these products offering centralized backup management for both database data, in conjunction with Recovery Manager (RMAN), and non-database data stored in file systems. Does Oracle Secure Backup support online backups of 3rd-party databases? No, Oracle Secure Backup does not provide native plug-ins of non-Oracle databases. NonOracle databases may be backed up offline (closed/consistent) as part of a file system backup. Consult with your vendor on best practices of backing up and recovering applications. Can Oracle Secure Backup share a server and/or tape resources with other backup applications? It is not recommended to install two backup applications on the same server or share tape hardware due to potential contention of resources. Overlapping background processes may be problematic causing unusual behavior for one or both backup applications. However, a partitioned library may be successfully shared between two applications.
The minimum recommended flash recovery area size on disk is dependent on the how frequent the backups are taken and retention policy used. If your configured retention policy is REDUNDANCY X and you plan to take a backup every Y days, then the formula for the recommended flash recovery area disk quota is: Disk Quota = Size of X copies of database + Size of one copy of incremental backups + Size of (Y+1) days of archived logs If you configure your retention policy to a recovery window of X days and execute your backup script once in Y days then you can calculate your required disk quota by one of two formulas. If X>=Y then the formula for the recommended flash recovery area disk quota is: Disk Quota = Size of one copy of database + Size of (floor(X/Y) + 1) copies of incremental backups + Size of (X * ceil(X/Y) +1) days of archived logs where ceil(X/Y) is the smallest integer greater than or equal to X/Y and floor(X/Y) is the largest integer less than or equal to X/Y. If X Disk Quota = Size of one copy of database + Size of 2 copies of incremental backups + Size of (Y +1) days of archived logs Size your flash recovery area according to the applicable formula. For this example, assume that the retention policy is REDUNDANCY 1: RMAN> CONFIGURE RETENTION POLICY TO REDUNDANCY 1; Also assume that backups will be performed daily. Daily Script The daily backup script would look like this: RMAN> RECOVER COPY OF DATABASE WITH TAG "whole_db_cpy"; # Make an incremental backup of the database to the flash recovery area. RMAN> BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG "whole_db_copy" DATABASE; Assume that there are no backups tagged "whole_db_copy" as of the first day of this backup scheme. The results of running this script daily are as follows: * On the first day, the RECOVER statement would have no effect, and the BACKUP... FOR RECOVER OF COPY would create the initial level 0 database copy. * On the second day, the RECOVER statement still has no effect, as there is no level 1 incremental backup to be applied to the level 0 incremental database copy. The BACKUP command creates the first incremental level 1 backup. * Each day after that, the incremental level 1 from the previous day is applied over the level 0
database copy, rolling it forward to the time of the incremental level 1 of the previous day, and a new incremental level 1 is created, containing all changes since the level 1 incremental backup of the previous day.
target database. Then issue the following SQL statement to enable change tracking: SQL> ALTER DATABASE ENABLE BLOCK CHANGE TRACKING; You can also create the change tracking file in a location you choose yourself, using the following SQL statement: SQL> ALTER DATABASE ENABLE BLOCK CHANGE TRACKING USING FILE '/mydir/rman_change_track.f' REUSE; The REUSE option tells Oracle to overwrite any existing file with the specified name. To disable change tracking, use this SQL statement: SQL> ALTER DATABASE DISABLE BLOCK CHANGE TRACKING; If the change tracking file was stored in the database area, then it is deleted when you disable change tracking. Checking Whether Change Tracking is Enabled From SQL*Plus, you can query V$BLOCK_CHANGE_TRACKING.STATUS to determine whether change tracking is enabled, and if it is, query V$BLOCK_CHANGE_TRACKING.FILENAME to display the filename. Moving the Change Tracking File If you need to move the change tracking file, the ALTER DATABASE RENAME FILE command updates the control file to refer to the new location. The process outlined in this section describes how to change the location of the change tracking file while preserving its contents. To relocate the block change tracking file: 1. If necessary, determine the current name of the change tracking file: SELECT filename FROM V$BLOCK_CHANGE_TRACKING; 2. Shut down the database. For example: SHUTDOWN IMMEDIATE 3. Using host operating system commands, move the change tracking file to its new location. 4. Mount the database and move the change tracking file to a location that has more space. For example: ALTER DATABASE RENAME FILE 'ora_home/dbs/change_trk.f' TO '/new_disk/change_ trk.f'; 5. Open the database: ALTER DATABASE OPEN; If you cannot shut down the database, then you must disable change tracking and re-enable it at the new location, as in the following example:
ALTER DATABASE DISABLE BLOCK CHANGE TRACKING; ALTER DATABASE ENABLE BLOCK CHANGE TRACKING USING FILE 'new_location'; If you choose this method, you will lose the contents of the change tracking file. Until the next time you complete a level 0 incremental backup, RMAN will have to scan the entire file.
blocks written to a backup set for each datafile with at least 50% of its blocks backed up: SELECT FILE#, INCREMENTAL_LEVEL, COMPLETION_TIME, BLOCKS, DATAFILE_BLOCKS FROM V$BACKUP_DATAFILE WHERE INCREMENTAL_LEVEL > 0 AND BLOCKS / DATAFILE_BLOCKS > .5 ORDER BY COMPLETION_TIME; Compare the number of blocks in differential or cumulative backups to a base level 0 backup. For example, if you only create level 1 cumulative backups, then when the most recent level 1 backup is about half of the size of the base level 0 backup, take a new level 0. Making Incremental Backups: BACKUP INCREMENTAL After starting RMAN, run the BACKUP INCREMENTAL command at the RMAN prompt. This example makes a level 0 incrementnal backup of the database: BACKUP INCREMENTAL LEVEL 0 DATABASE; This example makes a differential level 1 backup of the SYSTEM tablespace and datafile tools01.dbf. It will only back up those data blocks changed since the most recent level 1 or level 0 backup: BACKUP INCREMENTAL LEVEL 1 TABLESPACE SYSTEM DATAFILE 'ora_home/oradata/trgt/tools01.dbf'; This example makes a cumulative level 1 backup of the tablespace users, backing up all blocks changed since the most recent level 0 backup. BACKUP INCREMENTAL LEVEL = 1 CUMULATIVE TABLESPACE users; Incrementally Updated Backups: Rolling Forward Image Copy Backups Oracle's Incrementally Updated Backups feature lets you create an image copy of a datafile, then regularly create incremental backups of your database and apply them to that image copy. The image copy is updated with all changes up through the SCN at which the incremental backup was taken. RMAN can use the resulting updated datafile in media recovery just as it would use a full image copy taken at that SCN, without the overhead of performing a full image copy of the database every day. A backup strategy based on incrementally updated backups can help minimize time required for media recovery of your database. If you run scripts to implement this strategy daily, then at recovery time, you never have more than one day of redo to apply. Incrementally Updated Backups: A Basic Example To create incremental backups for use in an incrementally updated backups strategy, you must use the BACKUP... FOR RECOVER OF COPY WITH TAG form of the BACKUP command. How the command works is best understood in the context of an example script that would implement the strategy. This script, run on a regular basis, is all that is required to implement a strategy based on incrementally updated backups: RUN {
RECOVER COPY OF DATABASE WITH TAG 'incr_update'; BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG 'incr_update' DATABASE; } The syntax used in the script does not, however, make it clear how the strategy works. To understand the script and the strategy, it is necessary to understand the effects of these two commands when no datafile copies or incremental backups exist. * The BACKUP INCREMENTAL LEVEL 1... FOR RECOVER OF COPY WITH TAG... command does not always create a level 1 incremental backup. If there is no incremental level 0 backup of an individual datafile to use with this level 1 backup, then executing this command creates a level 0 backup of the datafile with the specified tag. Therefore, the first time the script runs, it creates the level 0 backup of the datafile needed to begin the cycle of incremental updates. In the second run and all subsequent runs, it produces level 1 incremental backups of the datafile. * The RECOVER COPY OF DATABASE WITH TAG... command causes RMAN to apply any incremental level 1 backups to a set of datafile copies with the same tag. If there is no incremental backup or no datafile copy, the command generates a message but does not generate an error. The first time the script runs, this command has no effect, because there is neither a datafile copy nor a level 1 incremental backup. The second time the script runs, there is a datafile copy (created by the first BACKUP command), but no incremental level 1 backup, so again, the command has no effect. On the third run and all subsequent runs, there is a datafile copy and a level 1 incremental from the previous run, so the level 1 incremental is applied to the datafile copy, bringing the datafile copy up to the checkpoint SCN of the level 1 incremental. Note also the following details about how this example works: * Each time a datafile is added to the database, an image copy of the new datafile is created the next time the script runs. The time after that, the first level 1 incremental for that datafile is created, and on all subsequent runs the new datafile is processed like any other datafile. * Tags must be used to identify the incremental backups and datafile copies created for use in this strategy, so that they do not interfere with other backup strategies you implement. (If you have multiple incremental backup strategies in effect, RMAN cannot unambiguously select incremental level 0 and level 1 backups for use in incremental backup and recover operations, unless they are tagged.) In practice, you would schedule the example script to run once each day, possibly at midnight. On a typical night (that is, after the first two nights), when the script completed the following files would be available for a point-in-time recovery: * An image copy of the database, as of the checkpoint SCN of the preceding run of the script, 24 hours earlier * An incremental backup for the changes since the preceding run * Archived redo logs including all changes between the checkpoint SCN of the image copy and the current time If, at some point during the following 24 hours, you need to restore and recover your database from this backup, for either complete or point-in-time recovery, you can restore the datafiles from the incrementally updated datafile copies, and apply changes from the most recent
incremental level 1 and the redo logs to reach the desired SCN. At most, you will have 24 hours of redo to apply, which limits how long point-in-time recovery will take.
The size of the backup file depends solely upon the number of blocks modified and the incremental backup level.
Using Compressed Backupsets For any use of the BACKUP command that creates backupsets, you can take advantage of RMAN's support for binary compression of backupsets, by using the AS COMPRESSED BACKUPSET option to the BACKUP command. The resulting backupsets are compressed using an algorithm optimized for efficient compression of Oracle database files. No extra uncompression steps are required during recovery if you use RMAN's integrated compression. This example backs up the entire database and archived logs to the configured default backup destination (disk or tape), producing compressed backupsets: BACKUP AS COMPRESSED BACKUPSET DATABASE PLUS ARCHIVELOG; This example backups up several datafiles to the default device, using binary compression: BACKUP AS COMPRESSED BACKUPSET DATAFILE 1,2,4; Predictably, creating compressed backupsets imposes some extra CPU overhead during backup and restore, which can slow the backup process. The performance penalty can be worth paying, however, in a number of circumstances: * If you are using disk-based backups and disk space in your flash recovery area or other disk-based backup destination is limited * If you are performing your backups to some device over a network and reduced network bandwidth is more important than CPU usage * If you are using some archival backup media such as CD or DVD, where reducing backup sizes saves on media costs and archival storage Note that performance while creating compressed backupsets is CPU bound. If you have more than one CPU, you can use increased parallelism to run jobs on multiple CPUs and thus improve performance.
BACKUP ARCHIVELOG FROM TIME 'SYSDATE-30' UNTIL TIME 'SYSDATE-7'; Automatic Online Redo Log Switches During Backups of Archived Logs When taking a backup of archived redo logs that includes the most recent log (that is, a BACKUP ... ARCHIVELOG command is run without the UNTIL or SEQUENCE option) if the database is open, then before beginning the backup, RMAN will switch out of the current online redo log group, and all online redo logs that have not yet been archived, up to and including the redo log group that was current when the commadn was issued. This ensures that the backup contains all redo that was generated prior to the start of the command. Using BACKUP ARCHIVELOG with DELETE INPUT or DELETE ALL INPUT You can specify the DELETE INPUT or DELETE ALL INPUT clauses for the BACKUP ARCHIVELOG command to delete archived logs after they are backed up, eliminating the separate step of manually deleting the archived redo logs. With DELETE INPUT, RMAN only deletes the specific copy of the archived redo log chosen for the backup set. With DELETE ALL INPUT, RMAN will delete each backed-up archived redo log file from all log archiving destinations. For example, assume that you archive to /arc_dest1, /arc_dest2, and /arc_dest3, and you run the following command: BACKUP DEVICE TYPE sbt ARCHIVELOG ALL DELETE ALL INPUT; In this case RMAN backs up only one copy of each log sequence number in these directories, and then deletes all copies of any log that it backed up from the archiving destinations. If you had specified DELETE INPUT rather than DELETE ALL INPUT, then RMAN would only delete the specific archived redo log files that it backed up (for example, it would delete the archived redo log files in /arc_dest1 if those were the files used as the source of the backup, but it would leave the contents of the /arc_dest2 and /arc_dest3 intact) . If you issue BACKUP ARCHIVELOG ALL or BACKUP ARCHIVELOG LIKE '...', and there are no archived redo log files to back up, then RMAN does not signal an error. Backing Up Logs with BACKUP ... PLUS ARCHIVELOG You can add archived redo logs to a backup of other files by using the BACKUP ... PLUS ARCHIVELOG clause. Adding BACKUP ... PLUS ARCHIVELOG causes RMAN to do the following: 1. Runs the ALTER SYSTEM ARCHIVE LOG CURRENT command. 2. Runs BACKUP ARCHIVELOG ALL. Note that if backup optimization is enabled, then RMAN skips logs that it has already backed up to the specified device. 3. Backs up the rest of the files specified in BACKUP command. 4. Runs the ALTER SYSTEM ARCHIVE LOG CURRENT command. 5. Backs up any remaining archived logs generated during the backup. This guarantees that datafile backups taken during the command are recoverable to a consistent state. To back up archived redo logs with BACKUP ... PLUS ARCHIVELOG: After starting RMAN, run the BACKUP ... PLUS ARCHIVELOG command at the RMAN
prompt . This example backs up the database and all archived logs: BACKUP DEVICE TYPE sbt DATABASE PLUS ARCHIVELOG; \
Including the Current Control File in a Backup Set To include the current control file in a backup set, specify the INCLUDE CURRENT CONTROLFILE option after specifying the backup object. In this example, the default configured channel is to an sbt device. This command backs up tablespace users to tape and includes the current control file in the backup: BACKUP DEVICE TYPE sbt TABLESPACE users INCLUDE CURRENT CONTROLFILE; If the autobackup feature is enabled, then RMAN also creates an autobackup of the control file after the BACKUP TABLESPACE command completes. Backing Up a Control File Copy This example creates a control file backup with the BACKUP CONTROLFILECOPY command. To back up a control file copy: After starting RMAN, run the BACKUP CONTROLFILECOPY command at the RMAN prompt. This example creates the control file copy '/tmp/control01.ctl' on disk and then backs it up to tape: BACKUP AS COPY CURRENT CONTROLFILE FORMAT '/tmp/control01.ctl'; BACKUP DEVICE TYPE sbt CONTROLFILECOPY '/tmp/control01.ctl';
While connected to the target database, run the BACKUP DATAFILECOPY command at the RMAN prompt. This example backs up datafile /tmp/system01.dbf to tape: BACKUP DEVICE TYPE sbt DATAFILECOPY '/tmp/system01.dbf';
RMAN> BACKUP DATABASE FORMAT '/tmp/%U'; # %U generates a unique filename You can also use the FORMAT argument to name an ASM disk group as backup destination, as shown in this example: RMAN> BACKUP DATABASE FORMAT '+dgroup1'; # sets an ASM disk group Optionally, use the TAG parameter to specify a backup tag. For example, enter: RMAN> BACKUP DATABASE TAG = 'weekly_backup'; # gives the backup a tag identifier RMAN assigns a default tag to backups.
is created as a backupset, then unused block compression will cause unused blocks to be omitted. For an image copy, the entire file contents are reproduced exactly. Note: A full backup is different from a whole database backup, which is a backup of all datafiles and the current control file.
Incremental backups can only be created for datafiles. Incremental backups of datafiles capture datafile changes on a block-by-block basis, rather than requiring the backup of all used blocks in a datafile. The resulting backup sets are generally smaller than full datafile backups, unless every block in the datafile is changed. During media recovery, RMAN examines the restored files to determine whether it can recover them with an incremental backup. When possible, RMAN chooses incremental backups over archived logs, because applying all changes to a block at once is faster than reapplying individual changes to the block from the redo logs.
desires, automatically executes a selected recovery plan. All DRA functions can be accessed via EM or RMANs command-line interface. Multisection Backups RMAN can back up or restore a single file in parallel by dividing the work among multiple channels. Each channel backs up one file section, which is a contiguous range of blocks. This speeds up overall backup and restore performance, and particularly for bigfile tablespaces, in which a data file can be sized upwards of several hundred GB to TB's. Fast Backup Compression In addition to the Oracle Database 10g backup compression algorithm (BZIP2), RMAN now supports the ZLIB algorithm, which offers 40% better performance, with a trade-off of < 20% lower compression ratio, versus BZIP2. Network-enabled Database Duplication A clone database on a remote site can now be easily created directly over the network with the enhanced DUPLICATE command, without the need for existing backups. Virtual Private Catalog A recovery catalog administrator can grant visibility of a subset of registered databases in the catalog to specific RMAN users. Integration with Windows Volume Shadow Copy Services (VSS) The Oracle database can participate in the VSS infrastructure on Windows platforms, with compatible backup management applications and storage systems. This feature allows VSSenabled backup management applications to snapshot the Oracle database and restore at the datafile, tablespace, or database level. Refer to the Backup and Recovery User's Guide for a complete list of new features. New Features in Oracle Database 10g Release 2 Backup Set Encryption Backup security is vital to the well-being of any company. Backups should only be able to be opened and read by their creators. With Oracle Database 10gR2, backup sets made to disk can now be encrypted, for the whole database or particular tablespaces, using the new CONFIGURE ENCRYPTION FOR [DATABASE | TABLESPACE ] option. Unused Block Compression With unused block compression (enabled by default), only the currently used blocks are read and written during a full backup. This speeds up backups and reduces backup size. In previous releases, blocks that are currently unused, but had been used at some point in the past, were required to continue to be backed up. Also, blocks that have never been used are never backed up. Dynamic Channel Allocation for RAC Environments By configuring the PARALLELISM parameter, RMAN will dynamically allocate the specified number of channels across all active RAC nodes, to perform the backup or restore operation. RMAN utilizes Oracle Clusterware (formerly known as Cluster Ready Services) to allocate channels to the least loaded nodes, to perform the operations. In this way, the overall backup or restore workload can be distributed across the RAC nodes more efficiently. Enterprise Manager Enhancements Oracle Enterprise Manager, a single, integrated solution for administering and monitoring systems and applications based on the Oracle technology stack, is further enhanced for managing and monitoring backup jobs.
Database Control allows DBAs to view all backup jobs by date range and backup type (e.g. full, datafile, archive log), along with their status (e.g. "completed", "completed with warnings"), input and output sizes, and output rate. Each backup job can be further drilled down to review input files and output backup sets/image copies, their sizes, and compression ratio (if enabled). Grid Control offers several enhancements to manage backups across the enterprise. Backup jobs can be viewed across all target databases, and a failed job can be easily restarted without having to resubmit the job again. In case a backup job fails, the DBA can be notified immediately via email. In addition, user-defined RMAN scripts can be created as jobs and applied to any number of target databases. The recovery wizard has also been enhanced to allow restore and recovery to a different Oracle home, in the event that the original Oracle home or database is lost.
Can one restore RMAN backups without a CONTROLFILE and RECOVERY CATALOG?
Can one restore RMAN backups without a CONTROLFILE and RECOVERY CATALOG? Details of RMAN backups are stored in the database control files and optionally a Recovery Catalog. If both these are gone, RMAN cannot restore the database. In such a situation one must extract a control file (or other files) from the backup pieces written out when the last backup was taken. Let's look at an example: Let's take a backup (partial in our case for ilustrative purposes): $ rman target / nocatalog Recovery Manager: Release 10.1.0.2.0 - 64bit Production Copyright (c) 1995, 2004, Oracle. All rights reserved. connected to target database: ORCL (DBID=1046662649) using target database controlfile instead of recovery catalog RMAN> backup datafile 1; Starting backup at 20-AUG-04 allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=146 devtype=DISK channel ORA_DISK_1: starting full datafile backupset channel ORA_DISK_1: specifying datafile(s) in backupset input datafile fno=00001 name=/oradata/orcl/system01.dbf channel ORA_DISK_1: starting piece 1 at 20-AUG-04 channel ORA_DISK_1: finished piece 1 at 20-AUG-04 piece handle= /flash_recovery_area/ORCL/backupset/2004_08_20/o1_mf_nnndf_TAG20040820T153256_0l czd9tf_.bkp comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45 channel ORA_DISK_1: starting full datafile backupset channel ORA_DISK_1: specifying datafile(s) in backupset including current controlfile in backupset including current SPFILE in backupset channel ORA_DISK_1: starting piece 1 at 20-AUG-04 channel ORA_DISK_1: finished piece 1 at 20-AUG-04 piece handle=
/flash_recovery_area/ORCL/backupset/2004_08_20/o1_mf_ncsnf_TAG20040820T153256_0l czfrx8_.bkp comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:04 Finished backup at 20-AUG-04[/code] Now, let's destroy one of the control files: SQL> show parameters CONTROL_FILES NAME TYPE VALUE ------------------------------------ ----------- -----------------------------control_files string /oradata/orcl/control01.ctl, /oradata/orcl/control02.ctl, /oradata/orcl/control03.ctl SQL> shutdown abort; ORACLE instance shut down. SQL> ! mv /oradata/orcl/control01.ctl /tmp/control01.ctl Now, let's see if we can restore it. First we need to start the databaase in NOMOUNT mode: SQL> startup NOMOUNT ORACLE instance started. Total System Global Area 289406976 bytes Fixed Size 1301536 bytes Variable Size 262677472 bytes Database Buffers 25165824 bytes Redo Buffers 262144 bytes Now, from SQL*Plus, run the following PL/SQL block to restore the file: DECLARE v_devtype VARCHAR2(100); v_done BOOLEAN; v_maxPieces NUMBER; TYPE t_pieceName IS TABLE OF varchar2(255) INDEX BY binary_integer; v_pieceName t_pieceName; BEGIN -- Define the backup pieces... (names from the RMAN Log file) v_pieceName(1) := '/flash_recovery_area/ORCL/backupset/2004_08_20/o1_mf_ncsnf_TAG20040820T153256_0 lczfrx8_.bkp'; v_pieceName(2) := '/flash_recovery_area/ORCL/backupset/2004_08_20/o1_mf_nnndf_TAG20040820T153256_0 lczd9tf_.bkp'; v_maxPieces := 2; -- Allocate a channel... (Use type=>null for DISK, type=>'sbt_tape' for TAPE) v_devtype := DBMS_BACKUP_RESTORE.deviceAllocate(type=>NULL, ident=>'d1'); -- Restore the first Control File... DBMS_BACKUP_RESTORE.restoreSetDataFile; -- CFNAME mist be the exact path and filename of a controlfile taht was backed-up DBMS_BACKUP_RESTORE.restoreControlFileTo(cfname=>'/app/oracle/oradata/orcl/control 01.ctl');
dbms_output.put_line('Start restoring '||v_maxPieces||' pieces.'); FOR i IN 1..v_maxPieces LOOP dbms_output.put_line('Restoring from piece '||v_pieceName(i)); DBMS_BACKUP_RESTORE.restoreBackupPiece(handle=>v_pieceName(i), done=>v_done, params=>null); exit when v_done; END LOOP; -- Deallocate the channel... DBMS_BACKUP_RESTORE.deviceDeAllocate('d1'); EXCEPTION WHEN OTHERS THEN DBMS_BACKUP_RESTORE.deviceDeAllocate; RAISE; END; / Let's see if the controlfile was restored: SQL> ! ls -l /oradata/orcl/control01.ctl -rw-r----- 1 oracle dba 3096576 Aug 20 16:45 /oradata/orcl/control01.ctl[/code] We should now be able to MOUNT the database and continue recovery... SQL> ! cp /oradata/orcl/control01.ctl /oradata/orcl/control02.ctl SQL> ! cp /oradata/orcl/control01.ctl /oradata/orcl/control03.ctl SQL> alter database mount; SQL> recover database using backup controlfile; ORA-00279: change 7917452 generated at 08/20/2004 16:40:59 needed for thread 1 ORA-00289: suggestion : /flash_recovery_area/ORCL/archivelog/2004_08_20/o1_mf_1_671_%u_.arc ORA-00280: change 7917452 for thread 1 is in sequence #671 Specify log: {=suggested | filename | AUTO | CANCEL} /oradata/orcl/redo02.log Log applied. Media recovery complete. Database altered. SQL> alter database open resetlogs; Database altered.
Secondly, you need to change your environment variables, and do a STARTUP NOMOUNT from sqlplus. This database is referred to as the AUXILIARY in the script below. Lastly, write a RMAN script like this to do the cloning, and call it with "rman cmdfile dupdb.rcv": connect target sys/secure@origdb connect catalog rman/rman@catdb connect auxiliary / run { set newname for datafile 1 to '/ORADATA/u01/system01.dbf'; set newname for datafile 2 to '/ORADATA/u02/undotbs01.dbf'; set newname for datafile 3 to '/ORADATA/u03/users01.dbf'; set newname for datafile 4 to '/ORADATA/u03/indx01.dbf'; set newname for datafile 5 to '/ORADATA/u02/example01.dbf'; allocate auxiliary channel dupdb1 type disk; set until sequence 2 thread 1; duplicate target database to dupdb logfile GROUP 1 ('/ORADATA/u02/redo01.log') SIZE 200k REUSE, GROUP 2 ('/ORADATA/u03/redo02.log') SIZE 200k REUSE; } The above script will connect to the "target" (database that will be cloned), the recovery catalog (to get backup info), and the auxiliary database (new duplicate DB). Previous backups will be restored and the database recovered to the "set until time" specified in the script. Notes: the "set newname" commands are only required if your datafile names will different from the target database. The newly cloned DB will have its own unique DBID.
The above Media Management Vendors will provide first line technical support (and installation guides) for their respective products. A complete list of supported Media Management Vendors can be found at: http://www.oracle.com/technology/deploy/availability/htdocs/bsp.htm When allocating channels one can specify Media Management spesific parameters. Here are some examples: Netbackup on Solaris: allocate channel t1 type 'SBT_TAPE' PARMS='SBT_LIBRARY=/usr/openv/netbackup/bin/libobk.so.1'; Netbackup on Windows: allocate channel t1 type 'SBT_TAPE' send "NB_ORA_CLIENT=client_machine_name"; Omniback/ DataProtector on HP-UX: allocate channel t1 type 'SBT_TAPE' PARMS='SBT_LIBRARY= /opt/omni/lib/libob2oracle8_64bit.sl'; or: allocate channel 'dev_1' type 'sbt_tape' parms 'ENV=OB2BARTYPE=Oracle8,OB2APPNAME=orcl,OB2BARLIST=machinename_orcl_archl ogs)';
2> allocate channel dev1 type disk; 3> restore (archivelog low logseq 78311 high logseq 78340 thread 1 all); 4> release channel dev1; 5> }