It’s so easy to use RMAN for Backups

It’s quite interesting that very many DBAs still use other methods than RMAN to backup their databases. I don’t mean the highend solutions like splitmirror but export / import or offline backups with OS-methods.

But it’s so easy to backup databases using RMAN:

  1. The database is running in archivelog mode. And I assume that this is true for every production database.
  2. There is an area or a directory for the oracle backups. In Oracle 11g Databases you probably already use the Fast Recovery Area (FRA) as the server parameter db_recovery_file_dest and db_recovery_file_dest_size are both defined. In this case the archiving can be enabled without additional parameters as well:
  3. sqlplus / as sysdba
    SQL> shutdown immediate
    SQL> startup mount
    SQL> ALTER DATABASE ARCHIVELOG;
    SQL> ALTER DATABASE OPEN;
    SQL> archive log list
    Database log mode              Archive Mode
    Automatic archival             Enabled
    Archive destination            USE_DB_RECOVERY_FILE_DEST
    Oldest online log sequence     35
    Next log sequence to archive   37
    Current log sequence           37

    This is sufficient for RMAN to backup the database as show in the following example:

    rman target /
    Recovery Manager: Release 11.2.0.2.0 - Production on Mon Dec 5 08:37:44 2011
    Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
    connected to target database: VMLIN112 (DBID=2882738724)
    RMAN> backup database;
    Starting backup at 05-DEC-11
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: SID=59 device type=DISK
    channel ORA_DISK_1: starting full datafile backup set
    channel ORA_DISK_1: specifying datafile(s) in backup set
    input datafile file number=00001 name=/u02/oradata/VMLIN112/system01.dbf
    input datafile file number=00002 name=/u02/oradata/VMLIN112/sysaux01.dbf
    input datafile file number=00003 name=/u02/oradata/VMLIN112/undotbs01.dbf
    input datafile file number=00004 name=/u02/oradata/VMLIN112/users01.dbf
    channel ORA_DISK_1: starting piece 1 at 05-DEC-11
    channel ORA_DISK_1: finished piece 1 at 05-DEC-11
    piece handle=/u03/orabackup/fast_recovery_area/VMLIN112/backupset/2011_12_05/o1_mf_nnndf_TAG20111205T083803_7frx6vfb_.bkp tag=TAG20111205T083803 comment=NONE
    channel ORA_DISK_1: backup set complete, elapsed time: 00:00:25
    channel ORA_DISK_1: starting full datafile backup
    set channel ORA_DISK_1: specifying datafile(s) in backup set
    including current control file in backup set
    including current SPFILE in backup set
    channel ORA_DISK_1: starting piece 1 at 05-DEC-11
    channel ORA_DISK_1: finished piece 1 at 05-DEC-11
    piece handle=/u03/orabackup/fast_recovery_area/VMLIN112/backupset/2011_12_05/o1_mf_ncsnf_TAG20111205T083803_7frx7olq_.bkp tag=TAG20111205T083803 comment=NONE
    channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
    Finished backup at 05-DEC-11

    As first task all database files are backed up (except the TEMP-Tablespace). As this is the first backup the controlfile and spfile are backed up into a separate backup piece. Since Oracle 11g a backup of the controlfile and spfile are made whenever there is a structural change to the database e.g. adding a tablespace or datafile.

In the FRA a new directory structure is created automatically (in the example it’s backupset/2011_12_15). The files do have a system generated name and tag to identify individual backups. This area will be maintained by the RMAN and archiver process. So as soon as the FRA reaches his maximum size (defined with db_recovery_file_dest) redundant files and directories are removed.

From my perspective this method is sufficient for smaller databases with some minor changes:

  1. As the controlfile backup does not uses that much space but the controlfile backup is essential for a full restore of the database I would recommend to add a controlfile backup to every database backup. The configuration parameter “controlfile autobackup on” enables this feature.:
  2. RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;

    This command changes the behavior of every backup because it’s stored as a parameter in the controlfile. You can see the actual values for several parameter with the command “show all“. Several DBA’s still use run-scripts with the complete configuration as those were common in earlier versions of RMAN. With Oracle 10g and 11g it’s no longer necessary to use those scripts in most cases instead it can be a bit tricky for restore and recovery as you need similar scripts. Storing the configuration in the controlfiles allows to use very simple commands to restore or recovery the database or parts of it – and I guess that’s more important than high sophisticated backup scripts.

  3. You can use on simple command to backup the database including the archivelogs but I would recommend two different commands like this:
  4. RMAN> backup database;
    
    RMAN> backup archivelog all not backed up 2 times;

    First the database is backed up and next all archivelogs are backed up as long as they are not backed up more than twice. This prevents archived redologs to be backed up too often but on the other hand they are available in the FRA as long as possible. Is already said RMAN and the archiver are maintaining the FRA in case the db_recovery_file_dest_size is reached.

You hopefully see how easy it is to use RMAN and that there is no reason why not to use it. Some more advantages of using RMAN are:

  1. RMAN does not simply copy the entire database but back up only blocks which are used or were in use earlier. So in most cases the size of the backup files is less than the size of the database.
  2. RMAN automatically verifies blocks so corruptions can be idenfied easier.
  3. Some basic information as well as statistics are available in several v$-views and can be viewed using enterprise manager or a nice little tool from Quest Software named Backup Reporter.

RMAN can also be used to make offline backups. But in this case the instance has to be mounted because RMAN needs to read the controlfile and has access to the database files. But in this case it’s not necessary to switch the database into archivelog mode which might be a good solution for development and test databases as well as for some data warehouses.

So give it a trial and tell me your experience – or simply chat with me if you need more information.

About Carajandb

I'm an Oracle professional for more than 20 years and founder of CarajanDB. As you can see because of the layout of my blog one of my hobbys is Kiting - and esp. Indoorkiting.
This entry was posted in Oracle, Oracle(E). Bookmark the permalink.

16 Responses to It’s so easy to use RMAN for Backups

  1. Pradip Patel says:

    I am Oracle DBA and love kiting. Also I am from one of the town which host international kite festival. Here is the few picture I belive you love it.

    http://www.google.com/search?q=international+kite+festival+2012&hl=en&rls=ig&site=webhp&prmd=imvns&tbm=isch&tbo=u&source=univ&sa=X&ei=lsBPT7ftN4nD0QGI2ZC1BA&sqi=2&ved=0CDAQsAQ&biw=1680&bih=994

  2. David Fuente says:

    Hi, I have a question about RMAN and I hope you can help me. I have a server with 3 databases and I would like to configure RMAN in one of them (due to licensing issues). Which is a better option controlfile or catalog?. I mean, three DB (A, B, C), one of them has the RMAN for example C, and the backup script pinpoint to he RMAN on C, but controlfile or catalog. Thanks in advance. Regards.

    • Carajandb says:

      Hi David
      I’m not absolutely sure that I understand your question but here are some suggestions about the RMAN catalog:
      If you backup your controlfile on regular basis, e.g. using CONTROLFILE AUTOBACKUP ON as I described in my blog, it’s not necessary to have a catalog as all relevant information about your backups is stored in the controlfile and it’s very easy nowadays to restore first the controlfile and than the rest of the database.
      But if you want to have a consolidated view of all your backups and being able to automate the whole restore a catalog will be nice.
      There are two major points to figure out:
      1. In case you need to restore the database (and you’re probably in trouble if your production environment is down) are you able to restore the whole database with some basic RMAN commands? If not: better use a catalog and OEM
      2. Can you guarantee that the catalog is available if you need to do a restore of your database (and keep in mind if you’ve lost your database there is a great chance the entire system crashed and needs to be retored)? If not: don’t use the catalog but train how to recover the databae in regular intervals.

      Does that help

      Johannes

  3. Muhammad Ibrar says:

    please explain me this statement

    rman target=’oracle/pswd@sistem1′ cmdfile “c:\data\rman.sql” log “c:\data\rmanlog.txt”

    • Carajandb says:

      Hi Muhammad
      in general I don’t see any issues with that statement. If the user “oracle” has sysdba privilege it should work (as long as you have valid statements in your rman.sql.
      Some minor comments:
      1. I would use a different script type (.rman instead of .sql) because it’s not sql but rman commands
      2. Try to use the same syntax “=” or blank and ” or ‘ for the entire command line
      But that does not have any impact to the execution itself

      Johannes

  4. John Knight says:

    Thanks Johannes for this article. I was not sure whether to employ a recovery catalgo or stick with using the controlfile but after reading this, I am going with the controlfile.Thanks again.

  5. sunil says:

    good doc…

  6. Erez says:

    Hi. Any idea why our rman would suddenly start splitting up the full backup file into multiple files? They are not all the same size and they are larger than 2GB, so I’m not sure why Oracle started to do this all of the sudden.. We used to have one large 62GB backup file, and now we have about 10 files ranging from 100MB to 12GB each.

    • Carajandb says:

      Hi Erez
      there are various reasons why the backup is splitted up into several pieces: MAXPIECESIZE, MAXSETSIZE, MAXOPENFILES, and the paralellism of course. But to help you finding a solution I need the rman configuration and some details about the last backup.

  7. Peter says:

    Why SPFILEs are backed up as backuppiece (*.bkp) even when I do a BACKUP AS COPY DATABASE?

    • Carajandb says:

      spfile belongs to the backup of the controlfile. So if CONTROLFILE_AUTOBACKUP = TRUE it will backup the controlfile and spfile every time you make any backup.
      –> I’ve moved my blog to blog.carajandb.com. Please use that blog for further discussions. <–

  8. Nitin says:

    Hi,

    could you please let me know how to move backups from its default location to new mount point if its previous mount point is about to get full.? how do we use rman in such case?and which will be the faster way to move backups to new location.

    • Carajandb says:

      Hi Nitin
      you can always configure a backup location manually:
      e.g.
      RMAN> CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT ‘/u03/orabackup/%d/%d-%Y-%M-%D-%p-%s.bck’;
      This will store rman backup in the directory /u03/orabackup//<databasename_YYYY-MM-DD–.bck

      –> I’ve moved my blog to blog.carajandb.com. Please use that blog for further discussions. <–

  9. Joy Gunnoo says:

    Hi,

    We are doing a full backup using RMAN but the file created is very big. While doing a backup of the file on tape this takes a long time. Is there a way of splitting the backup into several smaller files before we can back it to tape.

Leave a reply to sunil Cancel reply