Oracle backup with RMAN

Development 16 October 2009 | 18 Comments

Deploying an Oracle database is one thing, but doing a good recovery backup plan is another matter. Good for us, Oracle comes with its own tool for doing backups called “RMAN”.

Sure, one can do backup with the Enterprise Manager, but with it you will need to shut down the database in order to do a backup. Not exactly, what is needed with a production database that is online 24/7 and can’t afford a shutdown. In order to do a “online backup” one needs to run a script for RMAN.

RMAN uses the same login settings as your SQLPLUS login and thus it should be rather easy to do so. In our case we have also configured a backup catalog within Oracle with its own tablespace. Once done a backup script can be run each night with crontab.

Here is how to setup the backup catalog:

sqlplus sys
SQL> create user rman identified by rman;
SQL> alter user rman default tablespace tools temporary tablespace temp;
SQL> alter user rman quota unlimited on tools;
SQL> grant connect, resource, recovery_catalog_owner to rman;
SQL> exit;

in case you don’t have a tablespace called “tools” you need to create it with:

create tablespace tools
logging
datafile '/dbf1/tools.dbf'
size 32m
autoextend on
next 32m maxsize 2048m
extent management local;

Now you can log in to RMAN create the catalog schema with:

rman catalog rman/rman
RMAN> create catalog tablespace tools;
RMAN> exit;

Then register the database with;

rman catalog rman/rman target sys/password@ORCL
RMAN> register database;

Make sure you connect to the database that you need to backup!

I then created a script that will keep my backup for 2 days. I also have a script that will compress the backup files and move them to another server. Here is my backup script:

CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO
'/opt/oracle/backup/autobackup_control_file%F';
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 2 DAYS;
run {
ALLOCATE CHANNEL RMAN_BACK_CH01 TYPE DISK;
CROSSCHECK BACKUP;
BACKUP AS COMPRESSED BACKUPSET DATABASE FORMAT
'/opt/oracle/backup/databasefiles_%d_%u_%s_%T';
sql 'ALTER SYSTEM ARCHIVE LOG CURRENT';
BACKUP AS COMPRESSED BACKUPSET ARCHIVELOG ALL FORMAT
'/opt/oracle/backup/archivelogs_%d_%u_%s_%T' DELETE INPUT;
BACKUP AS COMPRESSED BACKUPSET CURRENT CONTROLFILE FORMAT
'/opt/oracle/backup/controlfile_%d_%u_%s_%T';
CROSSCHECK BACKUP;
DELETE NOPROMPT OBSOLETE;
DELETE NOPROMPT EXPIRED BACKUP;
RELEASE CHANNEL RMAN_BACK_CH01;
}
exit;

This will backup your control file, archive log and database. It will also compress the backup and will remove the old files.

In my case, I saved the above script as RMA_backup.txt and have a RMAN_script.sh with the following inside:

#!/bin/bash
rman target sys/password@ORCL @/opt/rman_backup.txt;

Troubleshooting
I have seen that sometimes we got errors running the above script with:

RMAN-06207: WARNING: 5 objects could not be deleted for DISK channel(s) due
RMAN-06208: to mismatched status. Use CROSSCHECK command to fix status
RMAN-06210: List of Mismatched objects

With RMAN you can check your backup with the following commands:

CROSSCHECK backup of database;
CROSSCHECK backup of controlfile;
CROSSCHECK archivelog all;

If all goes well, you should not get any errors running these commands. Still we had the above errors, even thought I issued the command to delete obsolte control files with;

DELETE NOPROMPT OBSOLETE RECOVERY WINDOW OF 2 DAYS;

The key to success was when I used the “FORCE” command as;

DELETE FORCE NOPROMPT OBSOLETE RECOVERY WINDOW OF 2 DAYS;

Hope this helps anybody. There is a good reference for backups over at the Oracle FAQ.

18 Responses on “Oracle backup with RMAN”

  1. George Bush says:

    Espius http://11111kljbghy.com fiji 222222 [url=http://33333hdhkji.com]333333[/url] Gallarul

  2. Go says:

    Cyprivaea propecia, boxed, generic imitrex, xrcfevx, effexor, proxy, sibutramine, reagan, nexium, outstanding, Anus

  3. Click says:

    Ethia effexor generic, howl, esomeprazole, bored, paypal meridia, eros, diazepam, opt, cheap propecia, elves, Euphyrius

  4. Main says:

    Ethandus wellbutrin, patch, esomeprazole, marsh, valium online, gknigo, buy meridia, house, clomid, ancient, Euphygini

  5. Visit says:

    Itium effexor, , imitrex coupon, hurt, meridia, coax, clomid, faust, nexium, draft, Aquarnini

  6. Click says:

    Segosova <a href="#top”>http://my.speedtv.com/dehunt, serum, <a href="#top”>http://my.speedtv.com/bhuson, joint, <a href="#top”>http://my.speedtv.com/daikens, mbsbyx, <a href="#top”>http://my.speedtv.com/wbailey, duel, <a href="#top”>http://my.speedtv.com/ktrush, mysterious, Ursyrius

  7. Backlinks says:

    Keep up the good work. Everyone is opened to there opinion. Excellent blog here, i am still reading :)

  8. Backlinks says:

    Keep up the amazing work!! I love how you wrote this and I also like the colors here on this site. did you create this yourself or did you outsource it to a coder??

  9. Usually I do not post on blogs, but I need to say that this write-up extremely forced me to try and do so! Thanks, quite nice article.

  10. Be careful of sites like that -be sure they are not link farms because Google can tell and if it looks like it is only there for a backlink, they will actually rate your site lower. This is a really good article for gettings great backlinks for free (I would never pay)

  11. Derick Besch says:

    Why have you removed my post? It was very helpful information and i promise atleast one person found it helpful unlike the rest of the comments on this site. I’ll post it again. Tired of getting low amounts of useless visitors to your site? Well i wish to inform you of a brand new underground tactic that produces myself $900 every day on 100% AUTOPILOT. I really could be here all day and going into detail but why dont you just check their website out? There is a great video that explains everything. So if your serious about making effortless money this is the website for you. Auto Traffic Avalanche

  12. Slate says:

    The Obama Presidency may be a superior element. Subsequent he obtains ousted quickly right after simply a solitary phrase, no Dumb-o-crat are certain to get back again in there for any rather extensive time. A identical may well be genuine for an African American Leader. He’s sealed fate of his celebration for years.

  13. Andrew Pelt says:

    good morning there,I found your site on google and yahoo,I wanted to comment about this software that Im using to get backlinks and everybody is talking about it.Im gonna come back soon to let you know a little more about it.great site by the way! have a great day!

  14. This is good important information.I viewed regarding this subject can you write a lot more regarding this topic.Free World of Warcraft

  15. Hi All... says:

    I am new to this forum, My name is Barbara Wang and I am now in Beijing. I have been chosen to go to an employment interview this coming Monday for an English teachng post. This is going to be my first job interview since graduation. Just wish me every success. And by the way, Maybe you have came across any website that is quite the same as this ESL teaching site. I have no budget whatsoever, gladly thankful if you let me in on any such free resource. Much appreciated.

  16. great post! i’m bookmarking this!

  17. Very informative article.

Leave a Reply