Whenever you have an oracle database problem and Oracle support asks you to upload the related trace files, the best option is to use the oracle Incident Packaging service to create an archive file that has all the necessary info to be uploaded to oracle.
If you just want to upload all the .trc files generated in the diagnostics trace directory (including but not limited to pmon traces), you can use the following script to generate such an archive file.
The following script accepts
- The directory name (The location of your trace files)
- The backup destination directory (The directory where you want the archive to be created. Ensure you have enough space here)
- The date of the trace files (DD-MON-YYYY)
- The begin time (HH24MI)
- The end time (HH24MI)
Then it finds all .trc files that falls in between those begin and end times for the date you specified, from the directory you specified and creates a tar.gz archive file in the destination directory you specified. It creates a directory named trcbakMonDD in your destination directory and places the file in that dir. You can download this file and upload it to oracle.
Usage Example :. /backtraces.sh /u01/11gr2/diag/rdbms/rk01/rk01/trace /tmp ’11-Sep-2012′ 1315 1340
The abov ecommand will backup all .trc files, from the directory /u01/11gr2/diag/rdbms/rk01/rk01/trace, that have a timestamp between 13:15 and 13:40 on 11th Sep 2012 to a tar Archive in the directory /tmp
I have only tested it on Oracle Enterprise Linux 5. (It is likely that the syntax for the Tar and date commands might be different on different platforms)
Find the script code below
#!/bin/bash #This script can be used to create a tar archive of trace files created in #The database diagnostics trace directory between a given time period #Author : Rajeev Ramdas if [ $# != 5 ] then echo ./backtraces.sh tracefiledir backupdir DD-Mon-YYYY HH24MI HH24MI echo ./backtraces.sh /u01/Rk/Docs/11g/Scripts2 /tmp '09-Nov-2012' 0900 1332 exit fi l_backup_base=$2 l_backdir=trcbak`date --date=${3} +%b%d` l_backdest=${l_backup_base}/${l_backdir} l_startdate=`date --date=${3} +%Y%m%d` l_enddate=`date --date=${3} +%Y%m%d` l_starttime="${l_startdate}${4}" l_endtime="${l_enddate}${5}" l_backfile="${l_backdest}/tracebak-${l_starttime}-${l_endtime}.tar.gz" if [ ! -d ${1} ] then echo Wrong Backup Dir exit 1 fi if [ ! -d ${2} ] then echo Wrong Backup Dest exit 1 fi if [ -d ${l_backdest} ] then echo Directory Exists else mkdir ${l_backdest} fi if [ -f ${l_backfile} ] then rm ${l_backfile} fi touch -t "$l_starttime" /tmp/tmpoldfile touch -t "$l_endtime" /tmp/tmpnewfile find $1 -type f -newer /tmp/tmpoldfile ! -newer /tmp/tmpnewfile -name '*.trc' | xargs tar -czvf - | cat > ${l_backfile} echo Your backup file is ${l_backfile} |
