Skip to Main Content
  • Questions
  • Script for to Backup Oracle Database

Breadcrumb

Question and Answer

Tom Kyte

Thanks for the question, Donald.

Asked: September 08, 2000 - 9:34 am UTC

Last updated: November 28, 2007 - 10:49 pm UTC

Version: 7.3.3

Viewed 1000+ times

You Asked

Do you have any script to backup an Oracle Database ONLINE where you dont have to shut down the services and that it doesn't need to export the whole database but only those records that are modified at that time so as to spend little time in exporting?

Thank you very much and more power !!!

and Tom said...



With Oracle7.3 -- no, there are no incemental backups. With Oracle8.0 and up there is a tool RMAN (recovery manager) that can do incremental backups of an Oracle database (only backup blocks modified since the last incremental or full backup for example).

With 7.3, you can certainly backup the database ONLINE using hot backups if the database is in archive log mode. You would place a tablespace into backup mode (alter tablespace T begin backup), copy all of the datafiles associciated with that tablespace elsewhere and then bring the tablespace out of backup mode via an alter statement again. Hot backups are easy to do -- I would recommend the Oracle8 Backup & Recovery Handbook -- Rama Velpuri, Anand Adkoli; for help in this area.

Hopefully, you are using the term "export" loosely. EXP is not a backup tool -- it is a point in time copy of the data. It is not good for recovering from media failures and other occurences where you need a point in time recovery.

Rating

  (5 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Hot Backup Script

atul, July 17, 2002 - 10:42 pm UTC

Hello sir,

I have written a script for daily hot backup..


Could you kindly help me in that

Script goes like this..

-----------------------------------------------------------------------------------------------


for i in `cat /tmp/sc1.lis`
do
echo "set heading off;\nset pages 0;\nALTER TABLESPACE '$i' BEGIN BACKUP ;\nexit"|sqlplus -s /
echo "set heading off;\nset pages 0;\nselect file_name from dba_data_files where tablespace_name ='$i' ;\nexit"|sqlplus -s / > /tmp/
w32.lis
for l in `cat /tmp/w32.lis`
do
cp $l /backup/.
done
echo "set heading off;\nset pages 0;\nALTER TABLESPACE '$i' END BACKUP ;\nexit"|sqlplus -s /
done
---------------------------------------------------------------------------------------------------------------

Where
vi /tmp/sc1.lis (Name of the tablespaces to be backed up)

TABLESPACE1
TABLESPACE2
TABLESPACE3



Actually we don't have development server so i can't test it..
so plz tell me will this script work??
or what changes should i do in it..


Thanks.
atul





Tom Kyte
July 18, 2002 - 8:25 am UTC

No, not really (not in the job of writing shell scripts)

Well, maybe I can help you out. You would be better served using RMAN. No OS dependent scripts -- it can be as easy as "backup database" basically. Suggest you look at RMAN.

incremental backups using rman

Duncan, December 08, 2003 - 11:48 am UTC

I would like to take incremental backups either cumulative or non. We have HP ultrium tapes but no license to use legato (or any other type of mms) so i am thinking about using rman to backup to disk and then archive using o/s commands.

My questions are:

1) How does rman decide on how to restore the database (possibly)using the incremental strategy? I mean in some cases it may be quicker (or more efficient) to do a restore from eg a level 2 and then roll forward using archive logs. In other cases it may be that it needs a level 0 and 3 level 2 backupsets before using the archive logs. So does RMAN actually make all of these decisions for you?

IF so then do i just need to decide on the best backup strategy for us eg

sun level 0
mon-fri level 2
sun level 1
mon-fri level 2
...
... etc

Then will rman decide on how to use these backupsets to achieve the desired restore?

2) If rman IS that clever and if i am manually archiving the backupsets to tape then how do i know which bacupsets RMAN is going to need to do a restore? Do i have to get all the available backupsets off of the tape and restore to disk before RMAN can decide and use the most efficient strategy??


Tom Kyte
December 09, 2003 - 5:30 am UTC

1) rman is not really going to analyze "it would be less work to restore the level 0 and then roll forward then to restore the level 0 and apply the N level and then roll forward". it'll restore the full, apply the needed incremental and roll forward pretty much.

2) you would need to restore anything it would want to use -- it assumes "all is where I put it last". You might consider getting some inexpensive ATA drives (you can get something like a terabyte for pretty little money) and keeing everything on magnetic storage and backing it up to tape using conventional means (file system dumps).

Thanks

A reader, December 09, 2003 - 6:48 am UTC


RMAN catalog Vs No Catalog

M. Senthil Kumar, December 09, 2003 - 10:25 am UTC

Hi Tom
Export can be used in addition to HOT backups or backups using RMAN. The export <<dmp>> can be used for retreival of data for a particular record. (If the user has accidently deleted the data , the dmp file will be useful in retrivel of the records). But this is not a solution for a large database where export takes a lot of time and disk space. In this case the logminer can be used for the retrival of the the record. Still it depends on how many records were deleted.
I do prefer RMAN and find it is much faster for back-up and retrivel. It depneds on the individual environment to choose catalog or no catalog option.

Incremental Data Export and Import - 8.1.7

Nazmul Hoque, November 28, 2007 - 2:22 am UTC

Dear Tom,

My Full Database installed in two localtion in diffrent server n same OS, Out of 210 table 100 are updateing only in one location and other 110 table are updateing in other location. I need to update table of both the location Daily basis by add the incemental data from the other part where it is updated.

Please advise me how i can export daily Incremental data of the selected table and also can import the same in other location. I am useing database 8.1.7 Enterprise Edition.

Thanks

Tom Kyte
November 28, 2007 - 10:49 pm UTC

you do not use export.

you might use materialized views.

read about them - goto otn.oracle.com and plug that into the documentation search.

More to Explore

Backup/Recovery

Check out the complete guide to all of the Backup & Recovery techniques in the Oracle Database.