Used managed backup means you take backup without any oracle feature. Suppose if you take backup by Operating system then it is called user managed backup. And the term hot backup means taking your backup whenever your database is at open state.
To take full database backup follow the following steps.
1)Before proceed remember you can take online/hot backup whenever your database is in Archivelog mode. If your database run on noarchivelog mode then you must take consistent backup that is after cleanly shutdown. In order to determine the archival mode, issue the query,
SQL> SELECT LOG_MODE FROM V$DATABASE;
LOG_MODE
————
ARCHIVELOG
If you see ARCHIVELOG then you can proceed further. In order to take backup while you are in noarhivelog mode follow other post on my blog.
2)Determine the files that you need to take backup.
Whenever you decide to take your database backup then take backup of data files , online redo log files ,control files, spfile.
In order to decide which files you need to backup issue the following query.
SQL>SELECT NAME “File Need Backup” FROM V$DATAFILE
UNION ALL
SELECT MEMBER FROM V$LOGFILE
UNION ALL
SELECT NAME FROM V$CONTROLFILE
UNION ALL
SELECT VALUE FROM V$PARAMETER WHERE NAME=’spfile’;
File Need Backup
——————————————————————————–
/oradata2/data1/dbase/system01.dbf
/oradata2/data1/dbase/undotbs01.dbf
/oradata2/data1/dbase/sysaux01.dbf
/oradata2/data1/dbase/users01.dbf
/oradata2/data.dbf
/oradata2/data1/data02.dbf
/oradata2/6.dbf
/oradata2/DBASE/datafile/o1_mf_permanen_42l31vg0_.dbf
/oradata2/data_test.dbf
/oradata2/data1/dbase/redo03.log
/oradata2/data1/dbase/redo02.log
/oradata2/data1/dbase/redo01.log
/oracle/app/oracle/product/10.2.0/db_1/dbs/cntrldupbase.dbf
/oracle/app/oracle/product/10.2.0/db_1/dbs/spfiledupbase.ora
13 rows selected.
So after running the above query I can say I need to backup 13 files.
3)Take the tablespace in backup mode rather than offline and read-only tablespace. In case of offline and read only tablespace you do not have to place the tablespace in backup mode because the database is not permitting changes to the datafiles.
You can check the status, tablespace_name and it’s associated data file name with the following query,
SELECT t.STATUS,t.TABLESPACE_NAME “Tablespace”, f.FILE_NAME “Datafile”
FROM DBA_TABLESPACES t, DBA_DATA_FILES f
WHERE t.TABLESPACE_NAME = f.TABLESPACE_NAME;
ORDER BY t.NAME;
Take the tablespace in backup mode rather than offline and read-only tablespace.
You can easily make a script of taking the online tablespace in backup mode by following query.
SQL>SELECT ‘ALTER TABLESPACE ‘ ||TABLESPACE_NAME ||’ BEGIN BACKUP;’ “Script” FROM DBA_TABLESPACES WHERE STATUS NOT IN (‘READ ONLY’,'OFFLINE’);
Script
————————————————————-
ALTER TABLESPACE SYSTEM BEGIN BACKUP;
ALTER TABLESPACE UNDOTBS1 BEGIN BACKUP;
ALTER TABLESPACE SYSAUX BEGIN BACKUP;
ALTER TABLESPACE TEMP BEGIN BACKUP;
ALTER TABLESPACE USERS BEGIN BACKUP;
ALTER TABLESPACE TEMP_T BEGIN BACKUP;
6 rows selected.
Alternatively, you can issue
SQL>ALTER DATABASE BEGIN BACKUP;
4)Copy the datafile to backup location.
After making a tablespace in backup mode take backup/copy of the associated datafiles. Here you can also make a script in order to copy datafiles to another location.
For online tablespace you must at first take it backup mode. You can check whether backup mode now active or not by issuing following query,
SQL>SELECT t.name AS “TB_NAME”, d.file# as “DF#”, d.name AS “DF_NAME”, b.status
FROM V$DATAFILE d, V$TABLESPACE t, V$BACKUP b
WHERE d.TS#=t.TS#
AND b.FILE#=d.FILE#
AND b.STATUS=’ACTIVE’;
SQL> SELECT ‘host scp ‘|| FILE_NAME || ‘ &backup_location ‘ “Backup Command” FROM DBA_DATA_FILES;
Enter value for backup_location: /backup
old 1: SELECT ‘host scp ‘|| FILE_NAME || ‘ &backup_location ‘ “Backup Command” FROM DBA_DATA_FILES
new 1: SELECT ‘host scp ‘|| FILE_NAME || ‘ /backup ‘ “Backup Command” FROM DBA_DATA_FILES
Backup Command
——————————————————————————————
host scp /oradata2/data1/dbase/system01.dbf /backup
host scp /oradata2/data1/dbase/undotbs01.dbf /backup
host scp /oradata2/data1/dbase/sysaux01.dbf /backup
host scp /oradata2/data1/dbase/users01.dbf /backup
host scp /oradata2/data.dbf /backup
host scp /oradata2/data1/data02.dbf /backup
host scp /oradata2/6.dbf /backup
host scp /oradata2/DBASE/datafile/o1_mf_permanen_42l31vg0_.dbf /backup
host scp /oradata2/data_test.dbf /backup
9 rows selected.
Also you can backup network files. Do a recursive search for *.ora starting in your Oracle home directory and under it.
In order to make script for to copy data files for those tablespace which are only in backup mode then issue,
SQL>SELECT ‘host scp ‘|| d.name ||’ &backup_location’ FROM V$DATAFILE d, V$TABLESPACE t, V$BACKUP b
WHERE d.TS#=t.TS#
AND b.FILE#=d.FILE#
AND b.STATUS=’ACTIVE’;
Run the script that you genereted.
On windows or other operating system you can use graphical browser to copy or other associated copy command.
5)Whenever you copy is finished make the tablespace out of backup mode. You can issue BEGIN BACKUP .. SCP serially (Take one tablespace in begin backup mode and then copy the associated datafiles and make the tablespace out of backup mode) or you can do it parallely(Take all tablespaces in begin backup mode and then copy the associated datafiles of all tabelspaces and then make the tablespace out of backup mode).
You here also make a script like,
SQL>SELECT ‘ALTER TABLESPACE ‘ ||t.name ||’ END BACKUP;’ “End Backup Script”
FROM V$DATAFILE d, V$TABLESPACE t, V$BACKUP b
WHERE d.TS#=t.TS#
AND b.FILE#=d.FILE#
AND b.STATUS=’ACTIVE’;
End Backup Script
———————————————————-
ALTER TABLESPACE SYSTEM END BACKUP;
You if you have taken Database in backup mode then issue
SQL>ALTER DATABASE END BACKUP;

You have taken only 9 datafile backup. What aboyt the redolog files,paramter files and control file that you have identified earlier ?
Dear Narayan,
Thanks for correction…here I come with correct one….
Before I took tablespace in backup mode I should
SQL> alter system archive log current;
System altered.
SQL> host cp ??/arch/* ??/backup2
SQL> alter database begin backup;
Database altered.
Then run the script to take the backup of all the datafiles.
SQL> alter database end backup;
Database altered.
SQL> alter system archive log current;
System altered.
SQL> host cp ??/arch/* ??/backup2
SQL> host cp ??/control01.ctl ??/backup2
SQL> host cp /??/control02.ctl ??/backup2
SQL> host cp ??/spfilesam.ora /??/backup
Hope this will help….once again thx for correcction and keep replying….
I liked your article is an interesting technology
thanks to google I found you
Dear All,
Please can you explain, what internal activities is performed by oracle while converting database in begin backup mode And new transaction, new database session.?
Whenever I put tablspace in backup mode it perform the below steps in details…..
1. Oracle checkpoints the tablespace, flushing all changes from shared memory to disk.
2. The SCN markes for each datafile in that tablespace are “frozen” at their current values. Even though further updates will be sent to the datafiles, the SCN markers will not be updated until the tablespace is taken out of backup mode.
3. Oracle switches to logging full images of changed database blocks to the redologs. Instead of recording how it changed a particular block the change vector), it will log the entire image of the block after he change. This is why the redologs grow at a much faster rate while hot backups are going on.
After this, your backup program works happily through this datafile, backing it up block by block. Since the file is being updated as you are reading it, it may read blocks just before they’re changed, after they’re changed, or even while they’re changing. Suppose that your filesystem block size is 4 KB, and Oracle’s block size is 8 KB. Your backup program will be reading in increments of 4 KB. It could back up the first 4 KB of an 8-KB Oracle data block before a change is made to that block, then back up the last 4 KB of that file after a change has been made. This results in what Oracle calls a “split block”. However, when your backup program reaches the point of the datafile that contains the SCN, it will back up that block the way it looked when the backup began, since that block is frozen. Once you take the tablespace out of backup mode, the SCN marker is advanced to the current value, and Oracle switches back to logging change vectors instead of full images of changed blocks.
Thanks & Regards,
Samadhan
Hi, I like your articles. very much straight forward. I am not as experienced as you are but i have one question.
You said before you put the tablespace in begin backup, you had done a manual switch of archive log by
alter system switch archive log current; I don’t see the what is the significance of this step before putting the db in begin back up. It does make sense to make manual switch after you end the back up.
I usually copy all archives to back up location after i do the manual switch after end back up. looks like you copy the archives between the 2 manual switches? is that correct?
Dear Tabrez,
Thx a lot for your valueable comments….!!!! Well i dont know where i said this exactly….
” You said before you put the tablespace in begin backup, you had done a manual switch of archive log by
alter system switch archive log current; ”
But while writing the scripts for backup generaly DBA’s follow the policy to mention switch log before the begin bkp and after the end bkp ( but before the cntrl bkp ).
Though there is no sense ( as u said) to switch log before begin bkp. Hope u must have got your answer.
Thx once agian and keep suggesting / commenting ….
Thanks & Regards,
Samadhan
Thank you for your swift response. You never said that but had mentioned the steps of log switch before begin back up.
I figured out why DBA’s usually do a manual switch before begin and then end back up and that is because they want to back up archives generated only during the two manual switches. so that you don’t have to back up all the archives right from the start.
this definitely is a good practice but not a mandatory one.Thanks!!!
You are definitely a talented guy
Dear Tabrez,
Thanks so much first of all for the kind words and for stopping by here. I am not that talented as you have kindly mentioned but still, I am thankful to you for your kind words.Ya you are true it is not mandatory…!!!!
Well thx a lot for your suggestion and keep replying / feedback.
Thanks & Regards,
Samadhan
sir
why do i have to take backup of redologfiles in hot backup ?
can i take backups without the redolog files and is it a valid backup ?
if my database is noarchivelog mode and i put all the tablespace in hot backup can i still take hot backup ? and do restore ?
i am new dba so i have lots of questions hope you understand it
Dear Sameer,
You can take hot backup without redo log file and it is valid backup.And if your database is in no arhivelog mode then first of all you can’t take hot backup. Hope i clear your douts. Let me know if you have any further query.
Thanks & Regards,
Samadhan
Niamatullah Raufi
thanks sir
what is instance recovery
Dear Niamatullah,
Oracle performs instance recovery when the database is restarted due to instance failure or shutdown the database with ABORT option(shutdown abort) or startup the database with FORCE option(startup force). Instance recovery is taken care by SMON oracle background process automatically. Instance recovery consists of two steps. One is Roll forward, next is Roll backward.
Thanks & Regards,
Samadhan
Niamatullah Raufi
sir
how we can improve oracle database perofarmance
Dear Niamatullah,
To improve the database performance we have to take care lots of point and it is realy big topic.You cant understand in single ans.
The different ways are there….
1)By writting the optimized query. http://samadhandba.wordpress.com/2011/10/24/how-to-write-tune-sql-queries-for-better-performance/
2)BY tunning the wait events. http://samadhandba.wordpress.com/2011/12/09/top-wait-events-resolving-common-oracle-wait-events/
like this so start reading the blogs and slowly you will get your answer.
Thanks & Regards,
Samadhan