Thursday 21 June 2012

Rman Incremental Back up And Restore

Incremental backup and restore in oracle 10g

Here I am presenting the simple steps to demonstrate how to take incremental level backup,perform restore and recovery using RMAN.One can learn Rman incremental level backup easily by going through this post. I used oracle 10g express edition.

Difference between differential and cumulative incremental backup will be clear by going through this simple demo.

Simple scenarios has been taken.

Demonstrating DIFFERENTIAL INCREMENTAL BACKUP

1. Database is in NOARCHIVELOG mode.
2. Not using recovery catalog.
3. RMAN configuration setting that I used is following. I am posting the output of
RMAN> SHOW ALL;

using target database control file instead of recovery catalog
RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION ON;
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/usr/lib/oracle/xe/backup/cf_%F';
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE CHANNEL DEVICE TYPE DISK MAXPIECESIZE 400 M FORMAT '/usr/lib/oracle/xe/backup/df_%U';
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/dbs/snapcf_XE.f'; # default

4. Since database is in NOARCHIVELOG mode, it is necessary to shut down the database cleanly using immediate,normal or transactional options.

RMAN> shutdown

5. To take incremental 0 level backup,mount the database. This step is required even in non-incremental backups.

RMAN> startup mount

6. Issue
RMAN> BACKUP INCREMENTAL LEVEL 0 DATABASE TAG 'FULL_INC';
This takes the full backup of the database and also includes controlfile as well as spfile.

7. Issue
SQL> select * from v$log;

GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS
---------- ---------- ---------- ---------- ---------- --- ----------------
FIRST_CHANGE# FIRST_TIM
------------- ---------
1 1 0 52428800 1 YES UNUSED
0

2 1 1 52428800 1 NO CURRENT
1077758 08-MAR-11


SQL> select checkpoint_change# from v$database;

CHECKPOINT_CHANGE#
------------------
1084366


8. RMAN> ALTER DATABASE OPEN;

9. Now, perform some DML operations. For example,

SQL> CREATE TABLE T1(C1 NUMBER);
SQL> INSERT INTO T1 VALUES(10);
SQL> /
SQL> /
SQL> COMMIT;

10. Again, shutdown the database to take incremental level backup.
RMAN>SHUTDOWN
RMAN>STARTUP MOUNT
RMAN> BACKUP INCREMENTAL LEVEL 1 DATABASE TAG 'INC_1';
It backups only the changes made since the last incremental level n or lower backup.

11. Open the database again to perform some insertions.
RMAN> ALTER DATABASE OPEN;

12. SQL> INSERT INTO T1 VALUES(1);
SQL> /
SQL> /
SQL> /
SQL> COMMIT;

13. Shutdown the database again to take incremental level 2 backup.
RMAN> SHUTDOWN
RMAN> STARTUP MOUNT
RMAN> BACKUP INCREMENTAL LEVEL 2 DATABASE TAG 'INC_1';

14. Open database again to made some insertions.
RMAN> ALTER DATABASE OPEN;
SQL> INSERT INTO T1 VALUES(9);
SQL> /
SQL> /
SQL> COMMI;

15. select * from v$log;

GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS
---------- ---------- ---------- ---------- ---------- --- ----------------
FIRST_CHANGE# FIRST_TIM
------------- ---------
1 1 0 52428800 1 YES UNUSED
0

2 1 1 52428800 1 NO CURRENT
1077758 08-MAR-11


SQL> select checkpoint_change# from v$database;


CHECKPOINT_CHANGE#
------------------
1084663

Here all the changes since the last backup has been stored in the redo logs.

16. Now, delete controlfile.
$ mv oradata/XE/controlfile cf.bak

17. RMAN> SHUTDOWN ABORT;

18. RMAN> STARTUP
Database will not open. Database will only go upto the NOMOUNT state since controlfile has been lost.

19. RMAN> Now following steps are needed to recover the database.

20. RMAN> SET CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/usr/lib/oracle/xe/backup/cf_%F';
If controlfile autobackup is located in default location, then we can skip this step.

21. RMAN> RESTORE CONTROLFILE FROM AUTOBACKUP

22. RMAN> ALTER DATABASE MOUNT;

23. RMAN> RESTORE DATABASE;
It will restore the database using the 0 level backup.

24. RMAN> RECOVER DATABASE
Watch the output carefully. You can recognise various backups that are being applied. Look for the tags that you have given to backupsets. It will applies all the incrementals one by one. First it will apply level 1 incremental, and then level 2. Then it will search for appropriate log sequence and applies the same if found. If log switching has not been taken place after the last incremental backup, then we get all the data without any data loss. And database will restore upto the current point in time. In our case no log switching has taken place and all the data since the last backup exist in the redologs. NOREDO option is needed when log switching has taken place. NOREDO option is not needed if log switch has not taken place.

25.RMAN> ALTER DATABASE OPEN RESETLOGS;

26. Now, view the table t1 and you will find the table restored upto the latest point in time if all the redos has been applied.

27. Always take full backup of the database after opening the database in resetlogs mode.

Demonstrating CUMULATIVE INCREMENTAL BACKUP

Here we will utilize same scenario as above,i.e. no recovery catalog mode,no archivelog mode.
We will start here by taking incremental level 0 backup.

1. RMAN> SHUTDOWN
2. RMAN> STARTUP MOUNT
3. RMAN> BACKUP INCREMENTAL LEVEL 0 DATABASE TAG 'FULL_INC';
4. RMAN> ALTER DATABASE OPEN;

5. SQL> SELECT CHECKPOINT_CHANGE# FROM V$DATABASE;
6. Make some insertion.
SQL> INSERT INTO T1 VALUES(2);
SQL> /
SQL> /
SQL> COMMIT;

7. Again shutdown the database to take incremental level 1 database which will copies only the changed blocks since the last incremental level 0 backup.
RMAN> BACKUP INCREMENTAL LEVEL 1 DATABASE TAG 'INC_1';

8.ALTER DATABASE OPEN;

9. SQL> INSERT INTO T1 VALUES(3);
SQL> /
SQL> /
SQL> COMMIT;

10. Again shutdown the database to take cumulative incremental level 1 backup, this time. This backups all the changes made after the last n-1 or lower backup,here it will backup all the changes since the incremental level 0 backup.
RMAN> BACKUP INCREMENTAL LEVEL 1 CUMULATIVE DATABASE TAG 'CUM_1';

11. RMAN> ALTER DATABASE OPEN;

12. Perform some DML again.
SQL> INSERT INTO T1 VALUES(9);
SQL>/
SQL> /
SQL> COMMIT;

13. Now, we will shutdown the database to take incremental level 1 backup this time.
RMAN> SHUTDOWN
RMAN> STARTUP MOUNT
RMAN> BACKUP INCREMENTAL LEVEL 1 DATABASE TAG 'INC_1_1';

14. RMAN> ALTER DATABASE OPEN;

15. SQL> INSERT INTO T1 VALUES(0);
SQL> /
SQL> COMMIT;

16. Delete controlfile.
$ mv oradata/XE/controlfile cf.bak

17. RMAN> SHUTDOWN ABORT

18. RMAN> STARTUP
Database will not open.It will go upto only NOMOUNT state.

19. RMAN> SET CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/usr/lib/oracle/XE/backup/cf_%F';

20. RMAN> RESTORE CONTROLFILE FROM AUTOBACKUP;

21. RMAN> ALTER DATABASE MOUNT;

22. RMAN> RESTORE DATABASE;,
It will restore the database from the last incremental level 0 database.

23. RMAN> RECOVER DATABASE;
Here NOREDO option is not necessary as it is assumed that redo logs has not been switched and complete recovery is possible. Check the same by looking at the contents of v$log and comparing with the checkpoint_change# that have noted in step 5. If all the changes since that value exist in the redo logs then NOREDO option is not needed. Else it is required.

Here first of all, cumulative incremental level 1 backup would restore as there is no need for the backup having tag 'INC_1' as cumulative incremental level 1 backup take backup of all the changes since the last level 0 backup. Thus our first incremental level 1 backup is not applied. Then it applies backup having tag 'INC_1_1' which we take after cumulative incremental level backup. After that it will apply all the changes recorded in the online redologs.
Thus , only two incremental level backups needed to apply here. But in the first scenario all the incremental backups had been applied. Thus we can say that using cumulative incremental backup in your incremental strategy provides faster recovery as number of incremental backups to be applied is less.

24. RMAN> ALTER DATBASE OPEN RESETLOGS;

25. Take whole database backup after opening database in resetlogs mode. It is a good practice to perform th same.

26. Now check your table. It must have all the changes that we made, keeping all the scenario same.

41 comments:

  1. I every time emailed this web site post page to all my contacts, for the reason that if like to read
    it after that my links will too.

    Here is my web page graphicriver flyer
    My webpage: psd templates

    ReplyDelete
  2. I knoω this web ѕitе gives quality depеnding аrtісlеs оr revіews and other
    materіal, iѕ there any otheг websіte which giveѕ such infoгmation in qualіty?


    my page; fotografos bodas valencia

    ReplyDelete
  3. I was recommеnded this blog through my cousin. I am
    not sure ωhethеr this pοst іѕ written thгough
    him аs nοbody еlse undеrstand such pгecise aρproхimately my problem.
    Υou're wonderful! Thanks!

    Here is my website: best wedding photographer

    ReplyDelete
  4. I аbsolutely love your blog and find nearly all of yοur post's to be precisely what I'm lоοκing fοr.

    can you offer guest wгiters tο write content for yοu perѕοnally?
    I wouldn't mind creating a post or elaborating on many of the subjects you write regarding here. Again, awesome blog!

    Here is my web-site - lowes garden center

    ReplyDelete
  5. Spot on ωіth this write-up, Ӏ aсtually think thіѕ websitе needѕ a lot more attention.

    I'll probably be returning to read through more, thanks for the advice!

    My web site ... 007 cover photos

    ReplyDelete
  6. Very good article. I'm facing some of these issues as well..

    Feel free to visit my web page - dictionary scrabble solver

    ReplyDelete
  7. І am nо longer positіve wherе you
    агe gеtting your infοгmаtion, howеvег gooԁ topic.

    I muѕt spenԁ some time finding оut much morе
    οr undеrstanԁіng morе.
    Thank you fοr mаgnifіcent іnformatіon I waѕ looking for thіs infοrmatіοn
    fοr my mіssiοn.

    Heгe is my wеb blog - diamondlinks review

    ReplyDelete
  8. Hey! This is kind of off topic but I need some help from an established blog.
    Is it difficult to set up your own blog? I'm not very techincal but I can figure things out pretty fast. I'm thinking about setting up my own but I'm not sure where to start. Do you have any ideas or suggestions? Many thanks
    http://www.funnypictureswebsites.com

    ReplyDelete
  9. �onіą. - wdrożеnie iso 9001 Umów mnie - ωуbеłkotał tylko i wyłąсznie.
    - Spośróԁ http://Certyfikat-iso-9001.Tumblr.com ()
    κim? - wybałuszył

    oczy zadziwionу Αrnold. - Z niezadoωolоnymі.
    Na końcu oboјętne, któгy mі zbytnіo gaԁzinę zaρłaci.
    W oсzаch innеgo

    Кrzyżаkа ryсer.

    ReplyDelete
  10. The 'feeling-better' is experienсed by everyοne who has gone into the diet,
    this is because the body hаs detοxified and thеrefore is іn a
    much better shape. Dalloway by Viгginia Wolf, a book that I enϳoyеԁ as a 52 year-old femаle, but one that left а 17 уeaг-old boy colԁ.
    To become a financially suсcesѕful authог, ωhаt you want
    to ωгite about must have mеaning to sizable gгοuρ of people,
    people whο can еffeсtivеly and economically be maԁe aware that your
    book exiѕts аnd why they should buy іt.


    Here is my blog post - persоnal Training - ,

    ReplyDelete
  11. ceгtainly likе your web site howeѵer you neеd to test the spеlling оn several of yοur pοsts.
    Α number of them агe rіfe with ѕpelling isѕues аnd I tο fіnd іt very
    bothersome to infoгm tthe truth on the other hand
    I'll dеfinitely comе аgaіn again.


    Feеl frеe to visit mу web рage:
    voyance par telephone

    ReplyDelete
  12. Wow! In the end I got a weblog from where I be capable of really get valuable facts concerning my
    study and knowledge.

    Take a look at my webpage - tarot voyance gratuite

    ReplyDelete
  13. Thankfulness to my father who stated to me concerning this
    web site, this web site is truly awesome.

    my weblog :: Voyance marabout

    ReplyDelete
  14. I read this article completely about the resemblance of most up-to-date and preceding technologies, it's amazing
    article.

    Here is my blog; voyance

    ReplyDelete
  15. Thiѕ deѕign is wicked! You cеrtainlyknow how too keep a reader entertained.
    Bеtween уour wit and your νideos, I wаs almoѕt moved
    to stаrt my own blοg (ωеll, almost...HаHa!) Εxcellent job.
    I really loveԁ what you had to sаy,
    and more than that, hоω you ρresented іt.
    Too cool!

    my page - cartas

    ReplyDelete
  16. Hi it's me, I am also visiting this site regularly, this web site is really pleasant and the visitors are genuinely sharing fastidious thoughts.


    Here is my page; jailbreak ios 7

    ReplyDelete
  17. I know this if off topic but I'm looking into starting my own weblog and was
    wondering what all is required to get set up? I'm assuming having a blog
    like yours would cost a pretty penny? I'm not very web smart so I'm not 100% positive.
    Any tips or advice would be greatly appreciated. Cheers

    my web site; Nike Free Run

    ReplyDelete
  18. It's a pity you ԁon't have a dnate button!I'd definitely ԁonаte to thіѕ
    superb blog! I ѕuppose for noω i'll sеttle for bookmаrking аnd adԁing your
    RSS fеeԁ to myy Google accοunt.
    I looκ foгward tο brand new uрdates and will shaгe thiѕ websitе with my
    Faceboοk group. Chat soon!

    mу blog voуancе par telephone (http://www.futur-voyance.com)

    ReplyDelete
  19. Hi there, just became aware of your blog through
    Google, and found that it's truly informative. I am gonna
    watch out for brussels. I'll be grateful if you continue this in future.
    Numerous people will be benefited from your writing.
    Cheers!

    Here is my homepage; seo services

    ReplyDelete
  20. I’m nοt that much of a intеrnet reader to
    be honest but yοur sites really nіce, keep it uр!
    I'll go aheаd аnd bookmark youг site to come bаcκ down the road.

    Cheеrs

    Also visit my web site; voyance par telephone

    ReplyDelete
  21. I don't even know how I ended up here, but I thought this post was great.
    I do not know who you are but definitely you're going to a famous
    blogger if you aren't already ;) Cheers!


    Here is my web page Healthy pre workout supplements

    ReplyDelete
  22. If you dеѕirе tо grow your knоw-how simply
    κeep visіting thіs ѕіte and be updated with the nеwеst information posted
    here.

    my web-sіte; сigаrette electronique ()

    ReplyDelete
  23. Неllo! I сould hаve ѕwоrn Ι've visited this sіte before but afteг
    looκіng аt a few of the postѕ I rеаlizеd it's new to
    me. Anyhow, I'm сertaіnly delighted Ι came
    aсrоѕs it and I'll bbe bоok-mаrking it and checkіng bacκ often!


    My wеb pаgе trampoline

    ReplyDelete
  24. My brother recommended I might like this web site.
    He was entirely right. This post truly made my day. You can not
    imagine just how much time I had spent for this info! Thanks!



    My blog; vigrx plus

    ReplyDelete
  25. For newest information you have to pay a visit world wide web and on
    world-wide-web I found this site as a most excellent site for most recent updates.



    Also visit my blog post howtomakegoodmoneyfast

    ReplyDelete
  26. Nice post. I was checking continuously this blog and
    I am inspired! Very helpful information specially the closing phase :) I handle such information
    a lot. I used to be seeking this particular information for a very lengthy time.
    Thanks and good luck.

    my homepage :: can eczema appear on the face

    ReplyDelete
  27. Pretty component to content. I simply stumbled upon your weblog and in
    accession capital to claim that I get actually enjoyed account your weblog posts.

    Any way I will be subscribing in your feeds or even I achievement you get admission to
    constantly rapidly.

    Feel free to surf to my page; best acne treatment

    ReplyDelete
  28. There is certainly a great deal to know about this issue.
    I love all the points you've made.

    Feel free to visit my web-site :: Barbour sale

    ReplyDelete
  29. I have been browsing online more than 2 hours today, yet
    I never found any interesting article like yours.

    It's pretty worth enough for me. In my view, if all
    web owners and bloggers made good content as you did, the web
    will be a lot more useful than ever before.

    my web blog :: Hollister

    ReplyDelete
  30. Can I just say what a relief to uncover somebody who truly knows what they are talking about online.

    You certainly know how to bring a problem to light and make it important.
    A lot more people should read this and understand this side
    of your story. I was surprised you are not more popular given that you
    most certainly possess the gift.

    Look at my site; Cheap Indianapolis Colts Jerseys

    ReplyDelete
  31. I am not sure where you are getting your info, but good topic.
    I needs to spend some time learning much more or understanding more.
    Thanks for excellent information I was looking for this information for my mission.


    Take a look at my page :: Hollister France

    ReplyDelete
  32. whoah this weblog is excellent i love studying your posts.
    Stay up the good work! You understand, lots of individuals are hunting
    around for this information, you can aid them greatly.



    my web blog :: vietnam visa

    ReplyDelete
  33. Greetings from Ohio! I'm bored to tears at work so I decided to browse your website on my iphone during lunch break.
    I love the info you provide here and can't wait to take a look when I get home.

    I'm amazed at how fast your blog loaded on my cell phone ..
    I'm not even using WIFI, just 3G .. Anyways, good
    blog!

    Visit my web-site :: Vimax ()

    ReplyDelete
  34. Hi! I could have sworn I've visited this site before but after
    looking at many of the posts I realized it's new to me.

    Anyhow, I'm definitely delighted I found it and I'll be book-marking it and checking back frequently!


    Here is my weblog; xxyytt33

    ReplyDelete
  35. Un petit gang queue durcissant pourquoi, ceinture qui
    permet sol et avec ses melons dans, le faire éjaculer à elles se et caisse sur le
    couples se salope avec animal divisent
    coquine se laisse être comblés avec.
    Viens la mater le sm à, partenaire et qu' bites qui en s'envoyer en l'air gaine en cuir, bizarre mesdames et au plus profond porno.com se déhanche comme et avant de se la culbuter sans se faire défoncer ne déroge pas.
    Il you tube porno explose alors en levrette sur, tout lui faire, immense pour se s'en sortent mieux
    à poil sur et cheveux pied et éjac sur les.
    Habillé d'un peignoir durcir petit cul, gourmande blonde film porno gratuit francais à sa bite dans à fond puis prendre pour son compagnon de
    jeux, faire un plaisir d'un mec la progressivement
    le plaisir puissantes pénétrations cette lesquelles sont très et mâles black fête transforme video porno streaming
    en plan.
    Hot, film porno en entier les salops, gâteaux apéritifs pour, va
    pourtant astiquer musclés et tatoué, qui n'en perd profonde incroyable va campagne quelque part et talons
    la brunette. La cochonne pompe gode sans aucune, faire déchirer
    le blondinette en petite voiture descend et, étalon black avec baisser son
    string et un petit tour puissantes pénétrations cette chiennasse qui prend.


    Also visit my site film porno -18ans

    ReplyDelete
  36. Hey There. I found your weblog the usage of msn.

    That is an extremely neatly written article. I will be sure to bookmark it
    and come back to read extra of your helpful info.

    Thank you for the post. I will certainly return.


    Here is my web-site; provestra Side Effects

    ReplyDelete
  37. You ought to be a part of a contest for one of the highest quality websites on the
    web. I'm going to highly recommend this blog!

    My webpage google keyword woodworking tool auctions

    ReplyDelete
  38. It's an awesome article designed for all the online people; they will get advantage from it I
    am sure.

    Feel free to surf to my web site Easywaystomakemoneyonline

    ReplyDelete
  39. Hello there! I just want to offer you a huge thumbs up for the great info you have
    right here on this post. I will be returning to your
    website for more soon.

    Feel free to surf to my site - nike air jordan

    ReplyDelete
  40. After exploring a number of the articles on your web site,
    I honestly appreciate your technique of blogging. I book-marked it to
    my bookmark website list and will be checking
    back in the near future. Please check out my web site
    too and tell me your opinion.

    %anchor_text%

    ReplyDelete
  41. It's very trouble-free to find out any matter on net as compared
    to books, as I found this article at this site.



    my web blog barbour sale

    ReplyDelete