Monday, November 1, 2010

Oracle RMAN Backup Solution (Open Source)

I have been searching for backup solution/tool for backup/recovery of Oracle Databases which is scalable enough that you can easily install and customize for your site. After spending some time on google/bing I felt it might be a good idea to work on one, which will give me an opportunity to refresh my skills in shell/perl scripting too. Finally after a good couple of months I was able to come up with a scalable product, which I have now uploaded to sourceforge.net as an open source Product. You can download the entire scripts from here https://sourceforge.net/projects/oraclerman/

 Zip file consists of 3 main scripts.

a ) scRBackup.sh : Single DB RMAN Backup Script(bash)
b ) scRRecover.sh: Single DB RMAN Recover Script(bash)
c ) scMBackup.pl : Multi DB Backup Wrapper Script(perl)


Script Usage Syntax


Before you read further, here's the backup script in action, small demo of how it works - desktop recording showing backup and restore of the databases. 

** If the video is not clear, a high resolution .avi file is included along with the scripts at https://sourceforge.net/projects/oraclerman/



Once you unzip the scripts are placed in folder called rbSCRIPTS and there are 3 main sub directories under this - rbLOGS, rbREPORTS, rbCONFIG, rbSQL. rbCONFIG/rbckup.ini: rbCONFIG consists of a .ini file called rbckup.ini, which contains all the initialization parameters required for the script to run. This eliminates the need to do edits or otherwise hard coding changes when you install this at your site. Instead you can do simple edits to the rbckup.ini file and customize it to work for your environment. Also makes it easy when you port the scripts from one host to another. The rbckup.ini, has been compartmentalized with comments like "Declared(DYN) meaning all Dynamic Variables", Declared (HC) meaning all Hard Coded Variables etc for readability. 


First set of arguments within rbckup.ini file is for command line arguments. For e.g. To backup a database RBPDB00, below is the command that will be used. As you can see all the RMAN parameters are being supplied through command line following the script name. This includes DISK vs. TAPE.

sh scRBackup.sh disk 0c RBPDB00 4 3 30 100G 4 1 2

If you notice within the rbckup.ini file, there's a line for "SBT_TAPE". This makes it easier to switch between a DISK backup a TAPE backup. Once you define the right nodes for TSM Backup (Assuming it's a TIVOLI TSM Tape Library and a tdpo.opt defined) all that's required to switch between disk and tape is that you need to specify that in the command line. Please note the quotes around (single and double), has to be precise, else the script will error out.

export SBT_TAPE="'sbt_tape' parms
'ENV=(TDPO_OPTFILE=/opt/tivoli/tsm/client/oracle/bin/tdpo.opt)'"

So if the above backup needs to be taken to the tape library, all you need to do is to change it to say "tape" instead of "disk"

sh scRBackup.sh tape 0c RBPDB00 4 3 30 100G 4 1 2

Above shows how to backup a single database "RBPDB00". So if you need to backup more than 1 database here's how it has to be done.

sh scRBackup.sh tape 0c RBPDB00 4 3 30 100G 4 1 2
sh scRBackup.sh tape 0c RBPDB01 2 5 60 200G 9 2 5

sh scRBackup.sh tape 0c RBPDB02 2 5 70 300G 8 4 3


As you can see above, the parameters (RMAN) followed by the databases can be different for different databases as you see fit. Details about these parameters has been described in the presentation (.ppt) included along with the code. For e.g, "0C" is for Incremental-Level-0-ColdBackup", "0 is for Incremental-Level-0-Open-Inconsistent Backup". Following the SID names are parameters like Channels, Recovery Window, Control File Record Keep Time, Max Set Size, Parallelism etc. I have included a Power Point Presentation (.ppt) which details each and every parameters along with the source code. You can download all these along with a demo from below link.



Since scRBackup.sh was being built to do individual Database Backups, I created a small file putting all the commands separated by ":" A perl wrapper called scMBackup.pl (Master Backup) is then used to read this file, which will just loop through and build the individual "scRBackup.sh x x x.." commands ript one by one looping through the supplied file.
rbCONFIG/db_dbf.lst
0:Y:scRBackup.sh:disk:0:RBPDB00:4:7:10:20G:2:1:1:EOL
1:Y:scRBackup.sh:disk:0:RBPDB01:6:9:15:50G:3:2:2:EOL
2:Y:scRBackup.sh:disk:0:RBPDB02:3:4:20:40G:4:1:2:EOL
3:Y:scRBackup.sh:disk:0:RBPDB03:4:2:50:90G:5:2:1:EOL

The syntax to use the scMBackup.pl is as below.

perl scMBackup.pl ./rbCONFIG/db_dbf.lst 0 3 R

The above command will scan the db_dbf.lst file and will build and run the individual scRBackup commands thus backing up each databases. The last letter "R", if substituted with "P" will give you a preview mode, instead really running the databases.

First character in each row is numbers in sequence, this is done so that instead editing the .ini file you can specify the start and end positions through the command line. For e.g, if you want to backup databases from 1 to 3, you will need to specify like below. This way the first one "0", will be skipped.

perl scMBackup.pl ./rbCONFIG/db_dbf.lst 1 3 R

Second character is provided for excluding any backups from the list. For e.g if there's list of 50 databases and you want to start from 0 to 50 but like to skip/disable the 30th one. Your .ini file would like below, substitute "Y", with "N". scMBackup.pl will thus skip this database. 


rbCONFIG/db_dbf.lst
0:Y:scRBackup.sh:disk:0:RBPDB00:4:7:10:20G:2:1:1:EOL
1:Y:scRBackup.sh:disk:0:RBPDB01:6:9:15:50G:3:2:2:EOL
..................
30:N:scRBackup.sh:disk:0:RBPDBxx:6:9:15:50G:3:2:2:EOL
...................
50:Y:scRBackup.sh:disk:0:RBPDB02:3:4:20:40G:4:1:2:EOL


All these can be tested by running it with preview mode - "P" , which will show what will run.



perl scMBackup.pl ./rbCONFIG/db_dbf.lst 0 50 P

For more details you may now go through the .ppt files included along with the demo (.avi) and scripts. For convenience and benefit I'm including same slides below. 


























Hope this helps. 

Regards,
Raj




*********************************************************************
The file is part of Open Source Oracle Backup Solution which uses RMAN+Perl+Bash script to backup Oracle Databases (11g & 10g) ready to run on any Linux Platforms by doing simple edits to an .ini file which may be required to be customized for your site.
Copyright (C) 2010 Baburaj Kallarakkal

Open Source Oracle Backup Solution is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published  by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
Open Source Oracle Backup Solution is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Open Source Oracle Backup Solution.

If not, see http://www.gnu.org/licenses.

**********************************************************************

36 comments:

  1. This comment has been removed by a blog administrator.

    ReplyDelete
  2. this is an execellent article ,very detail

    thanks

    ReplyDelete
  3. Simply a great tool, very well engineered and coded. I'm currently trying to make some changes need by our environment and surely adopt it as our main Oracle backup solution.

    ReplyDelete
  4. Will this script work on IBM AIX 5.3 and above ? I notice you mentioned this is only for Linux.
    How can I make it work on AIX ?

    ReplyDelete
  5. Oracle RMAN Backup Solution is very helpful and interactive. thanks for nice post.
    free downloadable software

    ReplyDelete
  6. thanks for giving great information of oracle rman backup solution.
    download free full version software

    ReplyDelete
  7. Thanks for informing about Oracle RMAN Backup Solution. it's really useful and interactive.
    new latest download

    ReplyDelete
  8. it is very useful post! thanks for giving nice information.
    free crack software | cracked software download

    ReplyDelete
  9. that's really awesome...thanks for giving informative post.
    android data recovery full crack

    ReplyDelete