Sunteți pe pagina 1din 13

Question: What are the RMAN backup types?

I see RMAN differential, RMAN cumulative and RMAN incremental backups, and I want to know the differences in the types of RMAN backups. Answer: RMAN is very flexible and it offers many different types of backups. We need to start with a list of backup types: Full backup: A full backup backs up all data files in the database, block-by-block, a standalone backup with everything you need to recover to the point in time when the full backup was collected. Level 1 backup: A level 1 backup includes only those blocks that have been changed since the parent backup was taken. Remember a parent backup may be either a level 0 or a level 1 backup. Level 0 backup: A level 0 incremental backup is physically identical to a full backup and it includes every data block in the file except empty blocks. The only difference is that the level 0 backup is recorded as an incremental backup in the RMAN repository, so it can be used as the parent for a level 1 backup. Incremental backup: An incremental backup can be either level 0 or level 1. There are two types of incremental backups, differential and cumulative. See my full notes on incremental differential vs. incremental cumulative backups.
Differential Incremental Backup: When using differential incremental backup (the default

type of incremental backup), RMAN looks for changed data blocks which were changed after last level 1 incremental backup. It theres no level 1 backup made before it, it takes a backup of the changed data blocks which were made after level 0 incremental backup.
Cumulative Incremental Backup: In a cumulative incremental backup RMAN takes

backup of all changed data blocks after level 0 or level 1 incremental backup. Like a differential backup, incremental backups also back up only the changed data blocks, but an incremental backup only backs up the data that has changed since the last backup. If the last backup was also an incremental backup, the current incremental backups only records changes to the changes, a much smaller set of block changes, and hence, a much smaller recovery time than a differential backup.

Incremental Differential vs. Incremental Cumulative Backups

Question: What are RMAN differential Backups and how are they different from cumulative RMAN backups? Are these the same as an RMAN incremental backup? Answer: Differential and cumulative are the two types of RMAN incremental backups. Its very confusing because RMAN differential backups are sometimes called "cumulative incremental backups" while RMAN incremental backups are sometimes called "differential incremental backups": Differential backup (for level 1 parents only): The default is differential backup, where RMAN looks for last level 1 or level 0 backup, and a differential backup only captures those data block changes that were made after those backups. Differential backups are faster because there are fewer changes stored, but they take longer at recovery time. Cumulative backup (for level 0 or level 1 parents): With a cumulative backup, RMAN backups up all data block changes that are made after a level 0 backup. The main advantage of cumulative backup over differential is the fast recovery time, but at the expense of a longer daily backup window and more disk usage. In a nutshell we see these advantages and disadvantages governing your choice of incremental cumulative vs. incremental differential backups. Recovery speed: Cumulative backups are faster to restore from than differential backups because fewer incremental backups need to be applied during recovery. Backup speed: For daily backup speed, differential backups run faster than cumulative backups because to dont duplicate the work done by previous backups. However, differential backups take longer when doing a recovery. Disk space usage: Cumulative backups take more disk space because they duplicate the work done by previous backups: Essentially, its a tradeoff between disk cost and recovery speed. All else being equal, the approach with the fastest recovery time is best because it minimizes unplanned downtime, and if you have plenty of disk and plenty of time to take nightly backups, you would choose incremental cumulative. If disk space is at a premium and you have only a short window to take daily backups, you would choose incremental differential, knowing that it will take longer to recover. Differential Incremental Backup (for level 1 parents only)

When using differential incremental backup, RMAN looks for changed data blocks which were changed after last level 1 incremental backup. It theres no level 1 backup made before it, it takes a backup of the changed data blocks which were made after level 0 incremental backup.

RMAN differential incremental backup. (Source: Oracle Corporation) Cumulative Incremental Backup (for level 0 or level 1 parent backups) In a cumulative incremental backup RMAN takes backup of all changed data blocks after level 0 or level 1 incremental backup. Like a differential backup, incremental backups also back up only the changed data blocks, but an incremental backup only backs up the data that has changed since the last backup. If the last backup was also an incremental backup, the current incremental backups only records changes to the changes, a much smaller set of block changes, and hence, a much smaller recovery time than a differential backup.

RMAN incremental backup tips


Oracle Tips by Burleson Consulting June 15, 2009

Incremental backups greatly reduce the elapsed time for Oracle backups, but the RMAN incremental backup mechanisms can be complex. In Oracle 10g and beyond, you can apply RMAN incremental backups to data file image copy backups to roll them forward to a specified point in time. This new feature provides the following benefits: By periodically updating image copies of data files with incremental backups, the updated image copy of the data file is moved forward to a more recent state (with more current SCN). This could potentially result in reduced recovery time. This use of RMAN incremental backups avoids performing a full image copy after incremental backups. The following statement rolls forward an image copy of data file u01/app/oracle/backup/grid/data01.imgcopy:
RMAN> recover datafilecopy /u01/app/oracle/backup/grid/data15.imgcopy;

Or, you can issue this command to perform the same operation:
RMAN> RECOVERY COPY OF DATAFILE 15;

When doing RMAN incremental backups with Oracle RMAN we need a mechanism to bypass those data blocks which have not changed. In a typical tablespace, SQL insert activity places new data blocks (as the tablespace and data file extends) in "hot" areas of the data file. To maximize the efficiency of RMAN incremental backups with block change tracking, try to use the APPEND hints with inserts or a low PCTUSED values for tables and indexes to ensure that all new rows are placed in new blocks. This reduces overhead, since only new blocks are tracked with the block change tracking mechanism. The syntax for Oracle block level change tracking is simple:
ALTER DATABASE ENABLE BLOCK CHANGE TRACKING USING FILE os_file_name;

Script to monitor RMAN progress


Server Tips by Burleson Consulting February 6, 2008

Question: I have a long running RMAN job, and I want a script to monitor the progress of RMAN execution. How do you monitor RMAN progress? Answer: Oracle has several views that can monitor long running jobs, including v$session_longops and v$process with v$session. Also see RMAN backup scripts from Windows DOS scripts for RMAN automated backups and example of RMAN shell script.
sselect sid, start_time, totalwork sofar, (sofar/totalwork) * 100 pct_done from v$session_longops where totalwork > sofar AND opname NOT LIKE '%aggregate%' AND opname like 'RMAN%'; select sid, spid, client_info, event, seconds_in_wait, p1, p2, p3 from v$process p, v$session s where p.addr = s.paddr and client_info like 'rman channel=%';

Yousef Rifai has published this RMAN monitoring script, quite handy when you need to monitor the status of a long running RMAN backup job:
REM RMAN Progress alter session set nls_date_format='dd/mm/yy hh24:mi:ss' / select SID, START_TIME,TOTALWORK, sofar, (sofar/totalwork) * 100 done, sysdate + TIME_REMAINING/3600/24 end_at from v$session_longops where totalwork > sofar AND opname NOT LIKE '%aggregate%' AND opname like 'RMAN%' / REM RMAN wiats

set lines 120 column sid format 9999 column spid format 99999 column client_info format a25 column event format a30 column secs format 9999 SELECT SID, SPID, CLIENT_INFO, event, seconds_in_wait secs, p1, p2, p3 FROM V$PROCESS p, V$SESSION s WHERE p.ADDR = s.PADDR and CLIENT_INFO like 'rman channel=%' /

Oracle rman backups from Windows Script


Oracle Tips by Burleson Consulting

Scheduling tasks such as an Oracle rman backup can be challenging in a Windows environment without a third-party approach such as SFU, JavaScript or Visual Basic. It's tricky, but you can write old-fashioned DOS bat files, a string of DOS prompt commands, to create an execute an Oracle rman backup. Also see these related RMAN scripts. Here is yet another RMAN script that will monitor the progress of your RMAN script. Example of RMAN shell script. Once tested, the bat file is invoked with the Windows AT scheduling command. For working examples of Oracle rman backups in Windows scripts, Jeff Hunter, author of "Conducting the Java Job Interview" has a great script to schedule an rman backup in a Windows environment. Lets examine Hunter's rman backup script. Note that he builds the exp parfile arguments into a DOS variable called %PARFILE%, just like you can invoke Oracle directly from the DOS prompt: e.g.
rman target %DB_USERNAME%/%DB_PASSWORD%@%TNS_ALIAS%

Above, note that this is all on one line, an important consideration when doping DOS bat file scripting. Here is Jeff's code:
REM +--------------------------------------------------------------------------+ REM | VALIDATE COMMAND-LINE PARAMETERS | REM +--------------------------------------------------------------------------+ if (%1)==() goto USAGE if (%2)==() goto USAGE if (%3)==() goto USAGE REM +--------------------------------------------------------------------------+ REM | VALIDATE ENVIRONMENT VARIABLES | REM +--------------------------------------------------------------------------+ REM set ORALOG=C:\oracle\custom\oracle\log REM set ORATMP=C:\oracle\custom\oracle\temp if (%ORALOG%)==() goto ENV_VARIABLES if (%ORATMP%)==() goto ENV_VARIABLES REM +--------------------------------------------------------------------------+ REM | DECLARE ALL GLOBAL VARIABLES. |

REM +--------------------------------------------------------------------------+ set set set set set set FILENAME=rman_backup_hot_full_9i DB_USERNAME=%1% DB_PASSWORD=%2% TNS_ALIAS=%3% CMDFILE=%ORATMP%\%FILENAME%_%TNS_ALIAS%.rcv LOGFILE=%ORALOG%\%FILENAME%_%TNS_ALIAS%.log

REM +--------------------------------------------------------------------------+ REM | REMOVE OLD LOG AND RMAN COMMAND FILES. | REM +--------------------------------------------------------------------------+ del /q %CMDFILE% del /q %LOGFILE% REM +--------------------------------------------------------------------------+ REM | WRITE RMAN COMMAND SCRIPT. | REM +--------------------------------------------------------------------------+ echo backup database plus archivelog delete input; > %CMDFILE% REM echo crosscheck backup of database; >> %CMDFILE% REM echo crosscheck backup of controlfile; >> %CMDFILE% REM echo crosscheck archivelog all; >> %CMDFILE% echo delete noprompt force obsolete;>> REM echo delete force noprompt expired REM echo delete force noprompt expired REM echo delete force noprompt expired echo exit; >> %CMDFILE% REM +--------------------------------------------------------------------------+ REM | PERFORM RMAN BACKUP. | REM +--------------------------------------------------------------------------+ rman target %DB_USERNAME%/%DB_PASSWORD%@%TNS_ALIAS% nocatalog cmdfile=%CMDFILE% msglog %LOGFILE% REM +--------------------------------------------------------------------------+ REM | SCAN THE RMAN LOGFILE FOR ERRORS. | REM +--------------------------------------------------------------------------+ findstr /i "error" %LOGFILE% if errorlevel 0 if not errorlevel 1 echo WARNING %FILENAME% %TNS_ALIAS% %COMPUTERNAME% %DATE% %TIME% %LOGFILE% echo echo echo echo echo echo echo echo ... END OF FILE REPORT Filename : %FILENAME% Database : %TNS_ALIAS% Hostname : %COMPUTERNAME% Date : %DATE% Time : %TIME% RMAN Log File : %LOGFILE% %CMDFILE% backup of database; >> %CMDFILE% backup of controlfile; >> %CMDFILE% archivelog all; >> %CMDFILE%

REM +--------------------------------------------------------------------------+ REM | END THIS SCRIPT. | REM +--------------------------------------------------------------------------+ goto END

REM +==========================================================================+ REM | *** END OF SCRIPT *** | REM +==========================================================================+ REM +--------------------------------------------------------------------------+ REM | LABEL DECLARATION SECTION. | REM +--------------------------------------------------------------------------+ :USAGE echo Usage: rman_backup_hot_full_9i.bat DBA_USERNAME DBA_PASSWORD TNS_ALIAS echo DBA_USERNAME = Oracle DBA Username - (Requires SYSDBA Role) echo DBA_PASSWORD = Oracle DBA Password echo TNS_ALIAS = Connect String to connect to the database (ex. ORCL) goto END :ENV_VARIABLES echo ERROR: You must set the following environment variables before echo running this script: echo ORALOG = Directory used to write logfile to echo ORATMP = Directory used to write temporary files to goto END :END @echo on

RMAN Installing OSB on Linux


Expert Oracle Tips by Burleson Consulting March 25, 2012

RMAN Installing OSB on Linux The software for the OSB is available as a download from the Oracle's OTN website. OSB's versioning is different from the rest of the database and it does not include special characters like g or i. The current version at the time of this writing is 10.3. When doing the installation of OSB over the Linuxenvironments, the recommended path is the /usr/local/oracle/backup folder. This folder is made by the root user and, from here, there must be an access to any sort of unzipping software. The unzipping needs to be done over the secure backup software downloaded from OTN. In addition to access to the unzipping software, the machines must be running over TCP/IP and also have a static IP. In addition to the above, before doing the installation, it is a must to make sure that there exists attach points for the devices which are used with OSB over the media server. An attach point is a logical name that is assigned to the physical device. The physical devices are mapped under the /dev folder as a file. An attach point is the naming convention through the device that is used by OSB. Oracle recommends using the /dev/sg interface for the devices. The sg is the interface that is used for SCSI devices. You may also refer to it as a sg driver for SCSI devices. To find the attach points over a Linux box, you can use the Linux command sg_map i x, finding the right mapping of the device with the interface at the lower level. Using this sg_map command, listings of the devices with their maps in the disk becomes evident. Once done, using the mkdev command, you can map these attach points. For example, here is one sample command from Oracle OSB docs which shows how you can map an attach point.
Mkdev t library O a machine1:/dev/sg4 vliba2

The software for the installation of OSB, as stated before, can be downloaded from OSB's home page, http://www.oracle.com/us/ products/database/secure-backup-066578.html. This page, besides having the download link, hosts many of the white papers related to it as well as lots of technical information about the same. The installation should be started from the folder which contains the downloaded and unzipped software of OSB. Once the software is downloaded and unzipped, you should start the installation from the folder where the installation files are extracted. As mentioned above, the installation should be done in the recommended location. The installation of OSB is done by the root user and is a command line installation. Below is the output of the installation summary which appears once you are done with the installation after supplying the answers to the questions that the installer asks you:

[root@localhost backup]# /home/oracle/osb-10.3.0.2.0_linux32/setup Welcome to Oracle's setup program for Oracle Secure Backup. This program loads Oracle Secure Backup software from the CD-ROM to a filesystem directory of your choosing. This CD-ROM contains Oracle Secure Backup version 10.3.0.2.0_LINUX32. Please wait a moment while I learn about this host... done. - - - - - - - - - - - - - - - - - - - - - - 1. linux32 administrative server, media server, client - - - - - - - - - - - - - - - - - - - - - - Loading Oracle Secure Backup installation tools... done. Loading linux32 administrative server, media server, client... done. - - - - - - - - - - - - - - - - - - - - - - Loading of Oracle Secure Backup software from CD-ROM is complete. You may unmount and remove the CD-ROM. Would you like to continue Oracle Secure Backup installation with 'installob' now? (The Oracle Secure Backup Installation Guide contains complete information about installob.) Please answer 'yes' or 'no' [yes]: - - - - - - - - - - - - - - - - - - - - - - Welcome to installob, Oracle Secure Backup's installation program. For most questions, a default answer appears enclosed in square brackets. Press Enter to select this answer. Please wait a few seconds while I learn about this machine... done. Have you already reviewed and customized install/obparameters for your Oracle Secure Backup installation [yes]? - - - - - - - - - - - - - - - - - - - - - - Oracle Secure Backup is not yet installed on this machine. Oracle Secure Backup's Web server has been loaded, but is not yet configured. Choose from one of the following options. The option you choose defines the software components to be installed. Configuration of this host is required after installation completes. You can install the software on this host in one of the following ways: (a) administrative server, media server and client (b) media server and client (c) client If you are not sure which option to choose, please refer to the Oracle Secure Backup Installation Guide. (a,b or c) [a]? Beginning the installation. This will take just a minute and will produce several lines of informational output. Installing Oracle Secure Backup on localhost (Linux version 2.6.18-128.el5)

You must now enter a password for the Oracle Secure Backup encryption key store. Oracle suggests you choose a password of at least 8 characters in length, containing a mixture of alphabetic and numeric characters. Please enter the key store password: Re-type password for verification: You must now enter a password for the Oracle Secure Backup 'admin' user. Oracle suggests you choose a password of at least 8 characters in length, containing a mixture of alphabetic and numeric characters. Please enter the admin password: Re-type password for verification: You should now enter an email address for the Oracle Secure Backup 'admin' user. Oracle Secure Backup uses this email address to send job summary reports and to notify the user when a job requires input. If you leave this blank, you can set it later using the obtool's 'chuser' command. Please enter the admin email address: generating links for admin installation with Web server updating /etc/ld.so.conf checking Oracle Secure Backup's configuration file (/etc/obconfig) setting Oracle Secure Backup directory to /usr/local/oracle/backup in /etc/obconfig setting local database directory to /usr/etc/ob in /etc/obconfig setting temp directory to /usr/tmp in /etc/obconfig setting administrative directory to /usr/local/oracle/backup/admin in /etc/obconfig protecting the Oracle Secure Backup directory creating /etc/rc.d/init.d/observiced activating observiced via chkconfig initializing the administrative domain ****************************** N O T E ****************************** On Linux systems Oracle recommends that you answer no to the next two questions. The preferred mode of operation on Linux systems is to use the /dev/sg devices for attach points as described in the 'ReadMe' and in the 'Installation and Configuration Guide'. Is localhost connected to any tape libraries that you'd like to use with Oracle Secure Backup [no]? Is localhost connected to any tape drives that you'd like to use with Oracle Secure Backup [no]? Installation summary: Installation Host OS Driver OS Move Reboot Mode Name Name Installed? Required? Required? admin localhost Linux no no no

Oracle Secure Backup is now ready for your use. As you can see, the installation that you have done is over a box which has been given the machine name localhost. This is the name that you have to use whenever you configure OSB; for example, in the database console! The information about the host that is chosen for the installation as the administrative domain is maintained within the config/host folder in a file named the same as the name of the machine. For your box, here are the contents of the localhost file:

[root@localhost host]# pwd /usr/local/oracle/backup/admin/config/host [root@localhost host]# more localhost name: localhost uuid: fc557e32-7f5a-102d-9aac-000c2926d8cd roles: ADMIN MEDIASERVER CLIENT cert key size: 1024 flags: 0x3 in service: yes ostype: LINUX_OS access mode: OB ip name: 192.168.0.103 algorithm: aes192 encryption: allowed keytype: transparent rekeyfrequency: 1 month [root@localhost host]#

This information can also be seen using the obtool's command lshost as well.
ob> lshost localhost admin,mediaserver,client (via OB) in service

The config folder not only contains the information of the host, it also contains all the configuration records which are created by either the web tool or the command line obtool. Once installed, you can view the information of the OSB by either CLI or GUI mode. You can see that you have logged in as admin user which is like the sys user of OSB. It is actually the root interface set via OSB. The information about this user and any other one configured can be retrieved from the already mentioned config/user object where each user created is maintained via a file named after his name. The password token for the admin is required at the time of the installation and you must remember it since it is needed to do any administrative work in OSB like creating a data selector which will be covered later. In case you have forgotten the admin user password, there is no way to retrieve it. What you need to do is reinstall, but you do not need to worry about losing all the configuration settings that you may have done while installing it earlier. Oracle keeps the configuration details but asks you for the new password.

RMAN sbttest Tips


Expert Oracle Tips by Burleson Consulting March 25, 2012

RMAN Using the sbttest Utility Oracle ships a utility to check and diagnose the media management API called sbttest. This utility does not do an actual backup but tries to communicate with the media management software to see if it is working properly or not. You do not need to download anything to start using this utility since it is shipped on the Unix platforms out-of-the-box and can be found under $ORACLE_HOME/bin. If your installation does not have it and you have a valid Oracle Support contract, you can ask OSS to send you the same and they will gladly do so. If you are going to use it over Solaris, you do not need to do any relinking of binaries, but on other platforms, using it requires a relink and would depend on your operating system and the product that you are using for taking the backup. You need to specify the correct API file that has to be used with the sbttest utility. If you do not mention anything, then the default API file for Unix platforms is libobk.so which is used for testing. For Windows, the API file name is orasbt.dll. The location of the files can vary and if you have already configured some MML software and are now upgrading, you may find redundant copies of the file as well. Make sure that you use only the most current version of the API file. Once you have relinked the utility successfully, all you need to do is go to the terminal and issue:
$sbttest help

This produces a long listing of the options available that you can use. sbttest can work for any file which is required to work with the media management API or directly with some mentioned datafile of which you want to take the backup. It is normally a good practice to include a trace file to record the output of the feedback. Once you have done the required configuration, a successful run of sbttest should look like this:
$sbttest test.out -trace sbttest.trace The sbt function pointers are loaded from libobk.so library. -- sbtinit succeeded -- sbtinit (2nd time) succeeded sbtinit: Media manager supports SBT API version 2.0 sbtinit: vendor description string=NMO v4.2.0.0 sbtinit: allocated sbt context area of 1176 bytes sbtinit: Media manager is version 4.2.0.0 sbtinit: proxy copy is supported sbtinit: maximum concurrent proxy copy files is 0 -- sbtinit2 succeeded -- regular_backup_restore starts

In case the utility doesn't work for any reason the output would be similar like shown below, The sbt function pointers are loaded from libobk.so library. -- sbtinit succeeded -- sbtinit (2nd time) succeeded sbtinit: Media manager supports SBT API version 2.0 sbtinit: Media manager is version 5.0.0.0 sbtinit: vendor description string=VERITAS NetBackup for Oracle - Release 5.0GA (2003103006) sbtinit: allocated sbt context area of 8 bytes sbtinit: proxy copy is supported -- sbtinit2 succeeded -- regular_backup_restore starts ................................ MMAPI error from sbtbackup: 7501, Failed to process backup file <test> -- sbtbackup failed [billtemp]oracle:/bill/appl/oracle/product/10.2.0/bin>

There is not just one set of error messages that you may get if the test fails. The errors would depend on what has gone wrong. Also, it is worth mentioning that even though sbttest runs successfully, it may still be possible that you will not be able to use the tape media properly. For example, if there is not a proper configuration done between the server and the media management layer, the actual backup may fail but sbttest results in a successful test.

S-ar putea să vă placă și