{"id":2650,"date":"2019-03-12T15:13:22","date_gmt":"2019-03-12T12:13:22","guid":{"rendered":"https:\/\/sysdba.org\/?p=2650"},"modified":"2019-03-12T15:13:22","modified_gmt":"2019-03-12T12:13:22","slug":"oracle-recovery-manager-rman-recovery-catalog-2","status":"publish","type":"post","link":"https:\/\/sysdba.org\/en\/oracle-recovery-manager-rman-recovery-catalog-2\/","title":{"rendered":"Oracle Recovery Manager (RMAN &#038; Recovery Catalog)"},"content":{"rendered":"<p><span style=\"text-decoration: underline;\">IT professionals should strive to check and answer the following :<\/span><\/p>\n<p>\u2022 If access to a database server is lost, what would the cost to a company be (monetary and reputation) ?<\/p>\n<p>\u2022 What is the maximum duration that a loss of access can be tolerated ?<\/p>\n<p>\u2022 If server X crashes, how long would it take to fully recover ? (Business continuity planning, working out the time to recover by carrying out a recovery procedure)<\/p>\n<p>\u2022 Are backups being taken and checked regularly ?<\/p>\n<p>\u2022 Verifying that the backups are working and are periodically tested<\/p>\n<p>\u2022 If the RAC1 server is offline, how quickly can it be put back online ?<\/p>\n<p>\u2022 What to do in a situation where RAC2 goes offline while RAC1 is offline ?<\/p>\n<p>\u2022 How soon can a RACx server be put back online ?<\/p>\n<p>\u2022 It is strongly advised to keep a step-by-step recovery guide ready, taking precautions is considered vital.<\/p>\n<p>(For example: Is there backup media ready and waiting to be removed immediately if there was a disaster such as a fire at a workplace ?)<\/p>\n<p>\u2022 Prepare documents that are easy to understand and could guide anyone to restore backups, in case of an emergency where you are unavailable and people couldn&#8217;t contact you.<\/p>\n<p>&nbsp;<\/p>\n<p>In this article we try to explain the subject of Oracle backups and in a separate article we will discuss restoring\/recovery.<\/p>\n<p>&nbsp;<\/p>\n<h3>RMAN (Recovery Manager)<\/h3>\n<p>This a built-in tool that comes with Oracle. It can be used to take backups of a database while it is open and can perform incremental backups.<\/p>\n<p>In addition to being able to perform block media recoveries, RMAN has many other features.<\/p>\n<p>&nbsp;<\/p>\n<h4><span style=\"text-decoration: underline;\">Terminology<\/span><\/h4>\n<p><strong>Target Database:<\/strong> The db to be backed up and restored.<\/p>\n<p><strong>RMAN Repository:<\/strong> The metadata collection about dbs used for backup, maintenance and recovery. This information is stored in control file records.<\/p>\n<p><strong>Recovery Catalog schema:<\/strong> The schema that holds the backup metadata, held in the recovery catalog database.<\/p>\n<p><strong>RMAN Client:<\/strong> A command line program used by client computers to connect to a database server, using specific connections and requires authentication, like SQL*Plus.<\/p>\n<p><strong>Backup Piece:<\/strong> The physical files that together form RMAN backup sets. Each piece file is in a proprietary binary RMAN format.<\/p>\n<p><strong>Backup Set:<\/strong> A number of files, including control files, datafiles, archived redo log files. There are one or more binary files per backup set.<\/p>\n<p><strong>Image Copy:<\/strong> An identical copy of single datafiles, archived redo log files or control files. They can be used to perform recovery without needing any modification.<br \/>\n[crayon]configure device type disk backup type to copy ;[\/crayon]<\/p>\n<p>RMAN backup information can be stored in 2 locations:<\/p>\n<p>1. In a controlfile<\/p>\n<p>2. In a recovery catalog<\/p>\n<p>If there are 1 or 2 Oracle servers in your company then you can use a controlfile. In scenarios where you have numerous databases, it would be better to store all their backup information in separate locations from a recovery standpoint, rather than in a single recovery catalog.<\/p>\n<p>A recovery catalog itself is an RMAN set of tables and views where repository data about one or more databases are kept.<\/p>\n<p>Additionally the catalog can store more metadata history information than a control file. RMAN scripts can also be kept in a recovery catalog that can be used to automate RMAN tasks.<\/p>\n<p>Perhaps the best feature of recovery catalogs are that it is possible to use them even if control files are damaged (using CONFIGURE CONTROLFILE AUTOBACKUP ON), however the recovery process takes longer using a recovery catalog instead of a control file. This becomes more apparent in the recovery\/restore scenario articles.<\/p>\n<p>NOTE: After every backup of target databases, a copy should be made of recovery catalog databases as they would contain the latest data.<\/p>\n<p><strong>Some Recovery Catalog recommendations:<\/strong><\/p>\n<p>The RC server should be in archive mode and the backup copies in a seperate location.<\/p>\n<p>A retention policy of higher than 1.<\/p>\n<p>Activating automatic backup of the control file.<\/p>\n<p>Not changing CONTROL_FILE_RECORD_KEEP_TIME values so that they are higher than the default values.<\/p>\n<p>To take online or hot backups using RMAN, the database needs to be in archive mode.<\/p>\n<p><strong>Archivelog Mode:<\/strong> Redo logs are stored as archives in order to return the database to a certain time. This is similar to a Windows restore point.<\/p>\n<p>For example: If a full backup was made on a Sunday and the system failed on a Wednesday. The database is first restored to its state as it was on Sunday, using a full backup, and archivelogs are then used to restore the database to its state between Sunday and Wednesday.<\/p>\n<p>Please refer to the article on placing a database into ArchiveLog Mode.<\/p>\n<p><strong>NoArchiveLog Mode:<\/strong> Redo logs can&#8217;t be archived in this mode.<\/p>\n<p>You can restore back to the point where a full backup was taken, which was Sunday in the example above, however it isn&#8217;t possible to access the data from then on until system failure.<\/p>\n<p><strong>Logical Backups:<\/strong> Backups made using the exp\/imp and exdp\/imdp tools. (Questions about logical backups appear in Oracle Certified Professional exams (version 9i)).<\/p>\n<p><strong>Physical Backups:<\/strong> A backup of the physical files, including data files, archive logs and control files.<\/p>\n<p>Having the target database and recovery catalog in separate instances\/servers is strongly recommended.<\/p>\n<p><strong>Levels of backup<\/strong><\/p>\n<p>\u2022 Backup of all database files (data file, control file, archivelog)<\/p>\n<p>\u2022 Backups made at the tablespace level (all of the datafiles in the tablespace)<\/p>\n<p>\u2022 A backup of the tablespace&#8217;s datafile can be made if the database is in archivelog mode.<\/p>\n<p>&nbsp;<\/p>\n<p>The configuration of the machines running the examples in this articles are as follows:<\/p>\n<table style=\"width: 345.333px;\">\n<tbody>\n<tr>\n<td style=\"width: 206px;\"><strong>Machine A<\/strong><\/td>\n<td style=\"width: 157.333px;\"><strong>Machine B<\/strong><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 206px;\">Oracle 10G 10.2.0.5<\/td>\n<td style=\"width: 157.333px;\">Oracle 10G<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 206px;\">RHEL 5.5<\/td>\n<td style=\"width: 157.333px;\">Oracle Solaris 10<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 206px;\">i386 CPU, 1284MB RAM<\/td>\n<td style=\"width: 157.333px;\"><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 206px;\">5 disk<\/td>\n<td style=\"width: 157.333px;\"><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 206px;\">Disk 1: OS<\/td>\n<td style=\"width: 157.333px;\"><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 206px;\">Disks 2,3,4,5: Included in the data and recovery asm (automatic storage management) group<\/td>\n<td style=\"width: 157.333px;\"><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p><strong>Creating a Recovery Catalog<\/strong><\/p>\n<p>1. Creating a tablespace<\/p>\n<p>2. Creating a user and granting privileges[crayon]CREATE TABLESPACE rec_cat DATAFILE<br \/>\n&#8216;+DATA\/orcl\/datafile\/rec_cat01&#8217; SIZE 100M AUTOEXTEND ON NEXT 10M MAXSIZE 1024M<br \/>\nLOGGING<br \/>\nPERMANENT<br \/>\nEXTENT MANAGEMENT LOCAL AUTOALLOCATE<br \/>\nBLOCKSIZE 8K<br \/>\nSEGMENT SPACE MANAGEMENT AUTO<br \/>\nFLASHBACK ON;[\/crayon]<\/p>\n<p>[crayon]CREATE USER cat IDENTIFIED BY cat<br \/>\nDEFAULT TABLESPACE rec_cat<br \/>\nTEMPORARY TABLESPACE &#8220;TEMP&#8221;<br \/>\nQUOTA UNLIMITED ON rec_cat;[\/crayon]<\/p>\n<p>[crayon]GRANT CONNECT,RESOURCE TO cat;<br \/>\nGRANT &#8220;RECOVERY_CATALOG_OWNER&#8221; TO CAT;<br \/>\nALTER USER CAT DEFAULT ROLE &#8220;RECOVERY_CATALOG_OWNER&#8221;;[\/crayon]<\/p>\n<p>[crayon]rman catalog cat\/cat<br \/>\ncreate catalog;[\/crayon]<\/p>\n<p>Procedures to run on the server where the Recovery Catalog is to be stored. (Backup information will be stored on a catalog server)<\/p>\n<p>As this is a test environment the recovery catalog server and the server where backup information is stored are the same.<\/p>\n<p>However in a production environment it is recommended having both sets of data on separate servers.<\/p>\n<p>[crayon]$rman target \/<br \/>\nRMAN&gt; connect catalog cat\/cat@orcl&lt;br&lt; a=&#8221;&#8221;&gt; \/&gt;RMAN&gt; register database;[\/crayon]<\/p>\n<p>The previous syntax shows that RMAN backups will now be stored in the recovery catalog.<br \/>\nConnecting with RMAN:<\/p>\n<p>[crayon]$rman<br \/>\nconnect target \/<br \/>\nalternatively<br \/>\n$rman target \/<br \/>\nRecovery Manager: Release 10.2.0.5.0 &#8211; Production on Thu Jun 16 14:15:13 2011<br \/>\nCopyright (c) 1982, 2007, Oracle. All rights reserved.<br \/>\nconnected to target database: ORCL (DBID=1257644776)[\/crayon]<\/p>\n<p>[crayon]$rman target sys\/sys@orcl<br \/>\nRecovery Manager: Release 10.2.0.5.0 &#8211; Production on Thu Jun 16 14:16:59 2011<br \/>\nCopyright (c) 1982, 2007, Oracle. All rights reserved.<br \/>\nconnected to target database: ORCL (DBID=1257644776)[\/crayon]<\/p>\n<p>It is now possible to connect to the target database.<\/p>\n<p>To connect to the remote machine the rman client needs to be compatible with the server. If they are not compatible:<\/p>\n<p>[crayon]RMAN-06429: TARGET database is not compatible with this version of RMAN \u00ab error message[\/crayon]<br \/>\nConnecting to the target database and catalog:<br \/>\n[crayon]rman TARGET sys\/sys@orcl CATALOG cat\/cat@orcl \u00ab recovery database is the same as the target database<br \/>\nRecovery Manager: Release 10.2.0.5.0 &#8211; Production on Thu Jun 16 14:14:34 2011<br \/>\nCopyright (c) 1982, 2007, Oracle. All rights reserved.<br \/>\nconnected to target database: ORCL (DBID=1257644776)<br \/>\nconnected to recovery catalog database[\/crayon]<\/p>\n<p>Connecting to the target database without a recovery catalog:<br \/>\n[crayon]$ rman TARGET sys\/sys@orcl NOCATALOG<br \/>\nRecovery Manager: Release 10.2.0.5.0 &#8211; Production on Thu Jun 16 14:13:18 2011<br \/>\nCopyright (c) 1982, 2007, Oracle. All rights reserved.<br \/>\nconnected to target database: ORCL (DBID=1257644776)<br \/>\nusing target database control file instead of recovery catalog[\/crayon]<\/p>\n<p>Running the parameter file (RMAN commands can be run after entering them into a parameter file)<\/p>\n<p>[crayon]$ rman @\/home\/oracle\/Batches\/rman.txt<br \/>\n$ rman sys\/sys@orcl catalog cat\/cat@orcl CMDFILE RmanParameter.txt log Rman.log[\/crayon]<\/p>\n<p>Connecting to the target db, creating a log and trace<br \/>\n[crayon]$ rman TARGET sys\/password NOCATALOG debug trace=rman.trc log=rman.log[\/crayon]<\/p>\n<p>Connecting to the target db, creating a log<br \/>\n[crayon]$ rman TARGET sys\/password log=rman.log APPEND[\/crayon]<\/p>\n<p>Backup information can be queried from the tables and views in the CAT schema.<\/p>\n<p><strong>Example Scenario:<\/strong> The Oracle database is not connected to the recovery catalog. If backups taken using RMAN were later saved on the recovery catalog, they might later need to be manually synchronized.<\/p>\n<p>The BACKUP and COPY commands to be used on the target database get automatically synchronized with the recovery catalog. A situations where changes made to the physical structure and there a high number of log switches might also need to be manually synchronized.<\/p>\n<p>[crayon][oracle@asm ~]$ rman TARGET sys\/sys@orcl CATALOG cat\/cat@orcl<br \/>\nRecovery Manager: Release 10.2.0.5.0 &#8211; Production on Thu Jun 16 14:21:22 2011<br \/>\nCopyright (c) 1982, 2007, Oracle. All rights reserved.<br \/>\nconnected to target database: ORCL (DBID=1257644776)<br \/>\nconnected to recovery catalog database[\/crayon]<\/p>\n<p>[crayon]RMAN&gt; RESYNC CATALOG;<br \/>\nstarting full resync of recovery catalog<br \/>\nfull resync complete[\/crayon]<\/p>\n<p><strong>Scripting<\/strong><\/p>\n<p>RMAN scripts can be copied to the recovery catalog or a text file.<\/p>\n<p>If using a Recovery Catalog, you could run a RC script directly.<\/p>\n<p>If you&#8217;re not using a recovery catalog then use the RMAN by entering this command: @\/path\/rman.txt<\/p>\n<p>[crayon]CREATE SCRIPT COMPRESSED_FULL_BACKUP {<br \/>\nALLOCATE CHANNEL C1 TYPE DISK ;<br \/>\nBACKUP AS COMPRESSED BACKUPSET DATABASE FORMAT &#8216;\/u01\/Rman\/%u&#8217; ;}[\/crayon]<\/p>\n<p>[crayon]CREATE SCRIPT COMPRESSED_FULL_BACKUP_ARC {<br \/>\nbackup as compressed backupset database format &#8216;\/u01\/Rman\/dbf_%d_%t_%s.rman&#8217; Tag=&#8217;DBF_Manual_%U&#8217;<br \/>\nplus archivelog format &#8216;\/u01\/Rman\/arc_%d_%t_%s.rman&#8217; tag=&#8217;Arc_Manual_%U&#8217; ;}[\/crayon]<\/p>\n<p>[crayon]CREATE SCRIPT TBS_USERS {<br \/>\nbackup as compressed backupset tablespace users format &#8216;\/u01\/Rman\/users-tbs.rman&#8217; Tag=&#8217;users-tbs_Manuel_16062011&#8242; ;}[\/crayon]<\/p>\n<p><strong>Running the scripts<\/strong><\/p>\n<p>[crayon]RUN<strong><br \/>\n<\/strong>{<br \/>\nALLOCATE CHANNEL C1 TYPE SBT ;<br \/>\nALLOCATE CHANNEL C2 TYPE SBT ;<br \/>\nBACKUP<br \/>\nFORMAT &#8216;FULL BACKUP_u%&#8217;<br \/>\nFILEPERSET 15<br \/>\nDATABASE;<br \/>\nRELEASE C1;<br \/>\nRELEASE C2;<br \/>\n}[\/crayon]<\/p>\n<p><strong>Checking the scripts<\/strong><\/p>\n<p>[crayon][oracle@asm ~]$ rman checksyntax @\/home\/oracle\/Scripts\/COMPRESSED_BACKUP<br \/>\nRecovery Manager: Release 10.2.0.5.0 &#8211; Production on Fri Jun 17 14:53:04 2011<br \/>\nCopyright (c) 1982, 2007, Oracle. All rights reserved.<br \/>\nbackup as compressed backupset database format &#8216;\/u01\/Rman\/dbf_%d_%t_%s.rman&#8217; Tag=&#8217;DBF_Manual_16062011&#8242;<br \/>\nplus archivelog format &#8216;\/u01\/Rman\/arc_%d_%t_%s.rman&#8217; tag=&#8217;Arc_Manual_16062011&#8242; ;<br \/>\nThe cmdfile has no syntax errors<br \/>\nRecovery Manager complete.[\/crayon]<\/p>\n<p>Saving the script to a text file<\/p>\n<p>[crayon]print script COMPRESSED_FULL_BACKUP_ARC to file &#8216;backupscript.txt&#8217; ;<br \/>\nscript COMPRESSED_FULL_BACKUP_ARC written to file backupscript.txt[\/crayon]<\/p>\n<p>The file should be in the same directory where RMAN was run.<\/p>\n<p>By creating global scripts it will be possible to use them in all databases that were saved to the recovery catalog.<\/p>\n<p>[crayon]create global script glb_full_backup<br \/>\n{<br \/>\nbackup database plus archivelog;<br \/>\ndelete obsolete;<br \/>\n}[\/crayon]<\/p>\n<p><strong>To view the contents of the global scripts<\/strong><\/p>\n<p>[crayon]print global script global_full_backup ;[\/crayon]<\/p>\n<p><strong>Listing the scripts<\/strong><\/p>\n<p>[crayon]LIST SCRIPT NAMES;<br \/>\nLIST GLOBAL SCRIPT NAMES;<br \/>\nLIST ALL SCRIPT NAMES;[\/crayon]<\/p>\n<p>[crayon]SELECT script_name FROM cat.rc_stored_script; &#8211;recovery catalog un sahibi<br \/>\nSELECT script_name, line, text FROM cat.rc_stored_script_line[\/crayon]<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Deleting the scripts<\/strong><\/p>\n<p>[crayon]delete script &#8216;script_ismi&#8217; ;<br \/>\ndelete global script &#8216;script_ismi&#8217; ;[\/crayon]<\/p>\n<p><strong>Running scripts on RMAN startup<\/strong><\/p>\n<p>[crayon]rman TARGET sys\/sys@orcl CATALOG cat\/cat@orcl SCRIPT &#8216;\/home\/oracle\/Scripts\/backup.sh'[\/crayon]<\/p>\n<p><strong>Configuring the backup channel and tool<\/strong><\/p>\n<p>[crayon]configure default device type to sbt ; &#8211;tape<br \/>\nconfigure default device type to disk ; &#8211;disk[\/crayon]<\/p>\n<p>The device selected by default can be changed for a pending backup<\/p>\n<p>[crayon]run<br \/>\n{<br \/>\nbackup database ;<br \/>\n}[\/crayon]<\/p>\n<p><strong>Tagging the backups<\/strong><\/p>\n<p>[crayon]backup tag &#8216;daily_full_backup&#8217; database ;<br \/>\nbackup format=&#8217;DBF_%d_%t_%s_%p&#8217; archivelog like &#8216;%Arc_dest%&#8217; ;[\/crayon]<\/p>\n<p><strong>Copying the RMAN backups<\/strong><\/p>\n<p>[crayon]run {<br \/>\nBACKUP DEVICE TYPE DISK<br \/>\nCOPIES 2 DATAFILE 5<br \/>\nFORMAT &#8216;\/u01\/y1\/dbf5_%U&#8217;, &#8216;\/u01\/y2\/dbf5_%U&#8217; ;<br \/>\n}[\/crayon]<\/p>\n<p>The syntax below shows how backups can be taken from an operating system to a separate location, the catalog command could be included in RMAN when required. There is an example scenario where this is shown.<\/p>\n<p><strong>Copying a backup to a different disk or tape<\/strong><\/p>\n<p>[crayon]backup device type disk as backupset database plus archivelog format &#8216;\/u01\/y2\/yy_%U&#8217; ;<br \/>\nbackup device type sbt as backupset database plus archivelog \u00ab from disk to tape<br \/>\nbackup device type sbt as backupset ALL[\/crayon]<\/p>\n<p><strong>Backup commands<\/strong><\/p>\n<p>[crayon]backup database ;<br \/>\nbackup tablespace tablespace_name ;<br \/>\nbackup datafile &#8216;+DATA\/orcl\/datafile\/examples&#8217; ; \u00ab Retrieve the datafile information from dba_data_files<br \/>\nbackup as copy database ;<br \/>\nbackup as copy tablespace examples ;<br \/>\nbackup as copy datafile &#8216;+DATA\/orcl\/datafile\/examples&#8217; ;<br \/>\nbackup tablespace examples TAG = &#8216;Daily_Backup&#8217; ;<br \/>\n[\/crayon]<\/p>\n<p><strong>Incremental Backup<\/strong><\/p>\n<p>Differential Incremental: The differences or changes since the last backup.<\/p>\n<p>Incremental level 0 = Full Backup (a backup of every used block, this is the base of the incremental backup)<\/p>\n<p>Listed below is an example of a weekly plan backup plan:<\/p>\n<p>Sunday level 0 \u00ab Take a full backup<\/p>\n<p>Monday incremental level 2 \u00ab No previous level 2 backup, so a backup of the difference since level 0<\/p>\n<p>Tuesday incremental level 2 \u00ab A previous level 2 backup, so the differences since the level 2 backup<\/p>\n<p>Wednesday incremental level 2 \u00ab A previous level 2 backup, so the differences since the level 2 backup<\/p>\n<p>Thursday incremental level 1 \u00ab No previous level 1 backup, if there was, a backup would have been made of the difference. Instead a backup is made from 0, this is a difference from a full backup from the middle of the week.<\/p>\n<p>Checking to see if any backups were made at the current level or at a more base level, if backups were made at a more base level (lower number) then a backup is made of the difference.<\/p>\n<p>[crayon]sun mon tues wed thurs fri sat sun<br \/>\n0 3 3 2[\/crayon]<\/p>\n<p>A full backup is taken on Sunday<\/p>\n<p>On Monday, the difference since Sunday is what gets taken as a backup.<\/p>\n<p>On Tuesday, a backup is made of the difference in the database state since Monday.<\/p>\n<p>On Wednesday, has a backup been made at the same level ? If not, a backup is made since the last closest level of backup, in this case a level 2 which was on Sunday.<\/p>\n<p>Logically it would be quicker to take a daily incremental backup after the full backup but taking a backup in this way is suprisingly slow, at least until the &#8220;block_change_tracking&#8221; feature has been activate.<\/p>\n<p>[crayon]set linesize 121<br \/>\ncol filename format a60<br \/>\nSELECT filename, status, bytes<br \/>\nFROM v$block_change_tracking;[\/crayon]<\/p>\n<p>[crayon]ALTER DATABASE ENABLE BLOCK CHANGE TRACKING<br \/>\nUSING FILE &#8216;\/oracle\/flash_recovery_area\/ORATR\/bctf01.log&#8217; ;[\/crayon]<\/p>\n<p>[crayon]SELECT filename, status, bytes<br \/>\nFROM v$block_change_tracking;[\/crayon]<\/p>\n<p>[crayon]ALTER DATABASE DISABLE BLOCK CHANGE TRACKING;[\/crayon]<\/p>\n<p>[crayon]SELECT filename, status, bytes<br \/>\nFROM v$block_change_tracking;[\/crayon]<\/p>\n<p>[crayon]backup incremental level 0 database plus archivelog;<br \/>\nbackup incremental level 1 database plus archivelog;[\/crayon]<\/p>\n<p><strong>First backup example<\/strong><br \/>\n[crayon]&#8211;Sunday<br \/>\nbackup incremental level 0 database plus archivelog;<br \/>\n&#8211;Monday<br \/>\nbackup incremental level 1 database ;<br \/>\n&#8211;Tuesday<br \/>\nbackup incremental level 1 database ;<br \/>\n&#8211;Wednesday<br \/>\nbackup incremental level 1 database ;<br \/>\n&#8211;Thursday<br \/>\nbackup incremental level 1 database ;<br \/>\n&#8211;Friday<br \/>\nbackup incremental level 1 database ;<br \/>\n&#8211;Saturday<br \/>\nbackup incremental level 1 database ;<br \/>\n&#8211;Sunday<br \/>\nbackup incremental level 0 database plus archivelog;[\/crayon]<\/p>\n<p><strong>Commands<\/strong><\/p>\n<p>The ALLOCATE CHANNEL and SWITCH parameters need to be placed in curly bracket. &lt;&gt;.<br \/>\n[crayon]run backup datafile 1;[\/crayon]<br \/>\n[crayon]backup as copy datafile 5 ;[\/crayon]<\/p>\n<p><strong>Deleting backups<\/strong><\/p>\n<p>If RMAN suggests deleting backups from the operating system, even though there is a solution for dealing with deleted backups it is recommended to not delete them.<\/p>\n<p>[crayon]delete archivelog all backed up 2 times to device type disk \u00ab Deletes archivelogs that have been backup up at least twice<br \/>\nBACKUP ARCHIVELOG ALL DELETE INPUT; \u00ab All archivelogs that have been backed up get deleted.<br \/>\n[\/crayon]<\/p>\n<p>Deleting backups that aren&#8217;t required (in accordance with the retention policy, more details ahead).<\/p>\n<p>[crayon]delete obsolete ;[\/crayon]<\/p>\n<p>Crosschecking whether Rman backups have been deleted by the operating system. Backups that can&#8217;t be found are marked as expired and erased using &#8220;delete expired&#8221;.<\/p>\n<p>[crayon]crosscheck archivelog all<br \/>\ncrosscheck backupset<br \/>\ncrosscheck backup[\/crayon]<\/p>\n<p>Deleting backups that have been marked as expired.<\/p>\n<p>[crayon]delete expired ;<br \/>\ndelete noprompt expired ; \u00ab Deletes the backups that are marked expired without prompting[\/crayon]<\/p>\n<p>Occasionally Rman scripts stops responding and without being able to control a script the archive logs start to get filled up. This could be followed by running out of diskspace and losing access. The only remaining option is to regain access at a local level.<\/p>\n<p>To create space as quickly as possible, in this situation, the oldest of the archive logs should be moved to another location or in the worst case should be deleted, however this is not recommended as it could cause problems.<\/p>\n<p>If the archive logs have been deleted by the operating system or moved to another disk, at this point it is possible to access the system by entering commands.<\/p>\n<p>[crayon]crosscheck archivelog all<br \/>\ndelete noprompt expired archivelog all<br \/>\nalter system switch logfile;[\/crayon]<\/p>\n<p><strong>Report commands<\/strong><\/p>\n<p>[crayon]report schema ; \u00ab Lists the data files in the target database[\/crayon]<\/p>\n<p>report obsolete ; \u00ab Lists the backups marked as obsolete (unused or unnecessary) according to the database&#8217;s retention policy. These backups can be deleted using the &#8220;delete obsolete&#8221; command. If the flash recovery area is used as the backup path, as long as there is available space in the path obsolete backups would continue being stored there, otherwise they get deleted. If backups are stored in a different area then they would need to be deleted manually (Scripts generally get deleted by writing into them, examples such as these will be shown in the scenario section inshALLAH)<\/p>\n<p>[crayon]report need backup ; \u00ab Files that require backups get listed according to the retention policy setting.<br \/>\nREPORT NEED BACKUP DEVICE TYPE sbt;<br \/>\nREPORT NEED BACKUP DEVICE TYPE disk;<br \/>\nREPORT NEED BACKUP TABLESPACE users DEVICE TYPE sbt;<br \/>\nREPORT UNRECOVERABLE ; \u00ab Shows database files that need to be urgently backed up due to nologging operations such as Direct-Path INSERT (As they haven&#8217;t created redo logs. (As they haven&#8217;t created redo logs, files that need to be backed up are listed).[\/crayon]<\/p>\n<p>Backup files that are unknown to Rman (not in its records) are used to inform Rman after the following has taken place:<\/p>\n<p>\u2022 The process of restoring the control file<\/p>\n<p>\u2022 Re-creating the control file<\/p>\n<p>\u2022 Changes to the db_recovery_file_dest parameters<\/p>\n<p>\u2022 Needing to restore backup files from a disk, separate to the one where the backups have been taken.<\/p>\n<p>[crayon]catalog datafilecopy &#8216;\/u01\/y1\/accounts01.dbf&#8217; ;<br \/>\ncatalog backuppiece &#8216;\/u01\/Rman\/ORCL_DB_1hmfeu60_49_1&#8217; ;<br \/>\ncatalog start with &#8216;\/u02\/Rman\/&#8217; ;[\/crayon]<\/p>\n<p>If there are inconsistencies between the physical backups on the disk and the backup records in Rman, they may get deleted. (There should be a backup of the backup before any deletion takes place. If there are any problems you could get support from Oracle and do a restore.)<\/p>\n<p>[crayon]delete force archivelog sequence 23 ;[\/crayon]<\/p>\n<p><strong>Listing the backups<\/strong><\/p>\n<p>[crayon]LIST BACKUP;<br \/>\nLIST BACKUP SUMMARY;<br \/>\nLIST COPY;<br \/>\nLIST ARCHIVELOG ALL;<br \/>\nLIST BACKUP OF DATABASE;<br \/>\nLIST INCARNATION;<br \/>\nLIST BACKUP BY FILE;<br \/>\nLIST COPY OF DATABASE ARCHIVELOG ALL;<br \/>\nLIST COPY OF DATAFILE 1, 2, 3;<br \/>\nLIST BACKUP OF DATAFILE 1 SUMMARY;<br \/>\nLIST BACKUP OF ARCHIVELOG FROM SEQUENCE 1453;<br \/>\nLIST CONTROLFILECOPY &#8220;\/u02\/backup\/CNTRLFILE.CP&#8221;;<br \/>\nLIST BACKUPSET OF DATAFILE 1;<br \/>\nLIST SCRIPT NAMES;<br \/>\nLIST GLOBAL SCRIPT NAMES;[\/crayon]<\/p>\n<p><strong>Checking the usability of the backups.<\/strong><\/p>\n<p>[crayon]validate backupset 5;[\/crayon]<\/p>\n<p>[crayon]RMAN-00571: ===========================================================<br \/>\nRMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============<br \/>\nRMAN-00571: ===========================================================<br \/>\nRMAN-03002: failure of validate command at 06\/22\/2011 13:09:06<br \/>\nRMAN-06004: ORACLE error from recovery catalog database: RMAN-20215: backup set not found<br \/>\nRMAN-06159: error while looking up backup set[\/crayon]<\/p>\n<p>[crayon]validate backupset 879;[\/crayon]<\/p>\n<p>[crayon]using channel ORA_DISK_1<br \/>\nchannel ORA_DISK_1: starting validation of datafile backupset<br \/>\nchannel ORA_DISK_1: reading from backup piece \/u01\/Rman\/19mfe9nl<br \/>\nchannel ORA_DISK_1: restored backup piece 1<br \/>\npiece handle=\/u01\/Rman\/19mfe9nl tag=TAG20110621T100748<br \/>\nchannel ORA_DISK_1: validation complete, elapsed time: 00:00:46[\/crayon]<\/p>\n<p><strong>RMAN settings<\/strong><\/p>\n<p>[crayon]show all; \u00ab Shows all available settings[\/crayon]<\/p>\n<p>The &#8220;# default&#8221; at the end of a sentence indicates that the values haven&#8217;t been changed at that they are still at their default settings.<\/p>\n<p>[crayon]CONFIGURE RETENTION POLICY TO REDUNDANCY 1; \u00ab Just stores a single backup, a value of 4 would mean setting it to store 4 backups.<\/p>\n<p>CONFIGURE BACKUP OPTIMIZATION ON; \u00ab If the tablespaces are read-only &amp; if there are backups of data that hasn&#8217;t been changed, another backup is made.<\/p>\n<p>CONFIGURE DEFAULT DEVICE TYPE TO DISK; \u00ab The default backup device could be set as a disk or tape.<\/p>\n<p>CONFIGURE CONTROLFILE AUTOBACKUP ON; \u00ab Ensures that the control file and spfiles are backed up when the structure of the database changes (adding or deleting dbf or redolog) and backups are made<\/p>\n<p>CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO &#8216;%F&#8217;; \u00ab Should be in %F format, it may be difficult to restore if changed.<\/p>\n<p>CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET;<\/p>\n<p>CONFIGURE DEVICE TYPE DISK PARALLELISM 1; \u00ab Can be increased according to the number of processors in order to speed up the backup process. This then increases the number of files that are created.<\/p>\n<p>CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; \u00ab Indicates the number of copies of the Datafile backups.<\/p>\n<p>CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; \u00ab Indicates the number of copies of the Archivelog files.<\/p>\n<p>CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT &#8216;\/u01\/Rman\/%d_DB_%u_%s_%p&#8217;; \u00ab The backup device, path and format.<\/p>\n<p>CONFIGURE MAXSETSIZE TO UNLIMITED; &#8211;CONFIGURE MAXSETSIZE TO 10G; \u00ab To set restrictions such as the backup files not being over 10Gb or restrictions on the hardware or the operating system.<\/p>\n<p>CONFIGURE ENCRYPTION FOR DATABASE OFF; \u00ab Encrypting the backups is vital for security purposes.<\/p>\n<p>CONFIGURE ENCRYPTION ALGORITHM &#8216;AES128&#8217;; \u00ab The setting for the encryption method or algorithm.<\/p>\n<p>CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; \u00ab If this is set to 2, backup Np 1. would be marked as obsolete and backup No. 2, i.e. the latest backup, would be set as the backup to be restored from.<\/p>\n<p>CONFIGURE SNAPSHOT CONTROLFILE NAME TO &#8216;\/u01\/y1\/snapcf_orcl.f&#8217; \u00ab The location where a snapshot of the control file is kept, used to synchronize with the catalog database.<\/p>\n<p>configure retention policy to recovery window of 7 days; \u00ab Retains all of the backups that have been taken for a period of 7 days, would not mark them as obsolete. Either one of the &#8220;windows&#8221; or &#8220;redundancy&#8221; keywords may be used but not both at the same ti\u00f6e<\/p>\n<p>Typing clear at the end of the statements would reset the setiting back to its defaults.<\/p>\n<p>CONFIGURE CONTROLFILE AUTOBACKUP clear ;<\/p>\n<p>configure backup optimization clear;[\/crayon]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>IT professionals should strive to check and answer the following<\/p>\n","protected":false},"author":1,"featured_media":3464,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[348,338],"tags":[345],"class_list":["post-2650","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dba_ii","category-oracle-tr","tag-oracle"],"_links":{"self":[{"href":"https:\/\/sysdba.org\/en\/wp-json\/wp\/v2\/posts\/2650","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sysdba.org\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sysdba.org\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sysdba.org\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sysdba.org\/en\/wp-json\/wp\/v2\/comments?post=2650"}],"version-history":[{"count":0,"href":"https:\/\/sysdba.org\/en\/wp-json\/wp\/v2\/posts\/2650\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sysdba.org\/en\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/sysdba.org\/en\/wp-json\/wp\/v2\/media?parent=2650"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sysdba.org\/en\/wp-json\/wp\/v2\/categories?post=2650"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sysdba.org\/en\/wp-json\/wp\/v2\/tags?post=2650"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}