Below is the script to backup control file to trace on unix to user defined location.
===========================================================
#------------------------------------------------------------
# backup controlfile
#------------------------------------------------------------
#------------------------------------------------------------
# find the user_dump_dest directory through a sqlplus call
# and assign it to an environment variable
#------------------------------------------------------------
ORA_DUMP=`${ORACLE_HOME}/bin/sqlplus -s << EOF
/ as sysdba
set heading off
set feedback off
SELECT value
FROM v\\$parameter
WHERE name='user_dump_dest';
exit
EOF`
#------------------------------------------------------------
# create backup controlfile
#------------------------------------------------------------
${ORACLE_HOME}/bin/sqlplus -s <<> /dev/null 2>&1
/ as sysdba
set heading off
set feedback off
ALTER DATABASE BACKUP CONTROLFILE TO trace;
exit
EOF
#------------------------------------------------------------
# find the trace file that the backup controlfile is in
# this should be the last trace file generated
# validate it is a controlfile and copy to backup_control.sql
#------------------------------------------------------------
DATETIME="`date '+%d%m%y'`"
CONTROL=`ls -t $ORA_DUMP/*.trc | head -1`
if [ ! -z "$CONTROL" ]; then
grep 'CONTROL' ${CONTROL} 1> /dev/null
if test $? -eq 0; then
cp ${CONTROL} /home/oracle/backup_control_file_$DATETIME.sql
fi
fi
#end
=========================================================
Sunday, March 14, 2010
How to backup control file to trace in Oracle Database?
Sunday, October 18, 2009
How to backup control file on windows?
Below is the command to backup control file to where ever location we want to.
alter database backup controlfile to trace as 'e:\ctl.txt';
How to backup control file to trace on unix???
===========================================================
#------------------------------------------------------------
# backup controlfile
#------------------------------------------------------------
#------------------------------------------------------------
# find the user_dump_dest directory through a sqlplus call
# and assign it to an environment variable
#------------------------------------------------------------
ORA_DUMP=`${ORACLE_HOME}/bin/sqlplus -s << EOF
/ as sysdba
set heading off
set feedback off
SELECT value
FROM v\\$parameter
WHERE name='user_dump_dest';
exit
EOF`
#------------------------------------------------------------
# create backup controlfile
#------------------------------------------------------------
${ORACLE_HOME}/bin/sqlplus -s <<> /dev/null 2>&1
/ as sysdba
set heading off
set feedback off
ALTER DATABASE BACKUP CONTROLFILE TO trace;
exit
EOF
#------------------------------------------------------------
# find the trace file that the backup controlfile is in
# this should be the last trace file generated
# validate it is a controlfile and copy to backup_control.sql
#------------------------------------------------------------
DATETIME="`date '+%d%m%y'`"
CONTROL=`ls -t $ORA_DUMP/*.trc | head -1`
if [ ! -z "$CONTROL" ]; then
grep 'CONTROL' ${CONTROL} 1> /dev/null
if test $? -eq 0; then
cp ${CONTROL} /home/oracle/backup_control_file_$DATETIME.sql
fi
fi
#end
=========================================================
Sunday, December 28, 2008
Steps to Re-Create the Control File
The follwing are the steps to re-create the control file....
1. First of all take the database to the "Mount" stage.
-->Alter database close;
2. Trace the control file.
The Trace file will be created in the "udump" directory.
-->Alter database backup controlfile to trace;
Note:-Trace the control file in "Mount" stage only.
3. Now shutdown the database gracefully and exit from sql.
-->shutdown immediate.
-->exit
4. Go to "udump" directory and pick the lastest trace file created.
-->You can use the following command to get the latest trace file in linux.
Issue this command in the "udump" directory.
-->ls -lrt
5. Open the lastest trace file.
-->vi latest_trace_file.trc
Note: In this trace file there will be two scripts.
1st one is used create the control file(which i'm telling in this post)
2nd one is used to rename the database(while i will be telling in the next post)
6. Remove everything in the trace file except the 1st script.
7. Save the trace file.
8. Copy the trace file to the home directory.
-->cp
9. Remove any old control file if it is there.
10. Connect to datbase as sysdba.
-->sqlplus / as sysdba
11. Start the database to "nomont" stage.
-->startup nomont.
12. Run the script file that we have created from the trace file.
-->@cont.sql
13. Now open the database.
-->Alter database open.
Now the crotrol file has been created, you can go to the control file diretory and check.