perl script for generates a report for backup times


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting perl script for generates a report for backup times
# 1  
Old 11-04-2010
perl script for generates a report for backup times

Hi all,

we do have daily oracle database backups and i need to generate report of each database start point and end point

we are using netapp snapshot(filer level) for backups.

all backups logs will be come in one directory

/u01/app/oracle/backup/hostname/log/*

here hostname=usadc*
for each host we have n number of databases

suppose i have hostname usadc01 and i have 5 databases residing in this and i take any one database say test
/u01/app/oracle/backup/usadc01/log/ in this path i will get 2 files for this database test.begin and test.end in these 2 files i will get database backup bagin time(test.begin) and database end time(test.end) here i need to parse these 2 files to take timestamp and need to direct to some file

and we have 40 servers and 300 databases

all servers will start from usadc in the path /u01/app/oracle/backup/

so in a loop i need to go one by one directory and for each server i need to go the path /u01/app/oracle/backup/usadc01/log/ here there will be n no of databases and for each database there will be 2 log files (*.begin and *.end) and i need to take the timestamp of these 2 files and need to direct to some file

i think this can be achived by perl it seems

is anybody there to advice me how i can go ahead.

appreciated a lot for help

thanks
# 2  
Old 11-04-2010
Post your input files (*.begin and *.end) and desire output.
# 3  
Old 11-04-2010
You don't need perl for this. You could use a for loop to go through the files and use stat(1) to get the timestamp.
# 4  
Old 11-04-2010
Code:
find /u01/app/oracle/backup -type f -name "*.begin" |where read file
do
  begin=$file
  end=${file%.*}.end
  #  parse these 2 files to take timestamp and need to direct to some file
done

# 5  
Old 11-11-2010
Hi,

oracle >more testdb.begin
---------------------------------------------------------------------------
11/10/10-02:47:30 --- testdb --- Beginning hot backup...
---------------------------------------------------------------------------
/mounts/testdb_data/oradata/testdb/dbfiles/system01.dbf
/mounts/testdb_data/oradata/testdb/dbfiles/sysaux01.dbf
/mounts/testdb_data/oradata/testdb/dbfiles/undotbs01.dbf
/mounts/testdb_data/oradata/testdb/dbfiles/users.dbf
/mounts/testdb_data/oradata/testdb/dbfiles/tools.dbf
/mounts/testdb_data/oradata/testdb/dbfiles/mpidata01.dbf
/mounts/testdb_data/oradata/testdb/dbfiles/redo01.log
/mounts/testdb_data/oradata/testdb/dbfiles/redo02.log
/mounts/testdb_data/oradata/testdb/dbfiles/redo03.log
/mounts/testdb_data/oradata/testdb/dbfiles/control01.ctl
/mounts/testdb_temp/oradata/testdb/tmpfiles/temp01.dbf
GROUP# THREAD# SEQUENCE# MEMBERS STATUS
---------- ---------- ---------- ---------- ----------------
1 1 601 1 INACTIVE
2 1 602 1 INACTIVE
3 1 603 1 CURRENT
Switching logfile...
System altered.

---------------------------------------------------------------------------
11/10/10-02:47:44 --- testdb --- Running: Alter database begin backup.
---------------------------------------------------------------------------

Database altered.
6 files out of 6 are in backup mode.
oracle >more testdb.end
---------------------------------------------------------------------------
11/10/10-03:15:29 --- testdb --- Finishing hot backup...
---------------------------------------------------------------------------

---------------------------------------------------------------------------
11/10/10-03:15:32 --- testdb --- Running: Alter database end backup.
---------------------------------------------------------------------------

Database altered.
0 files out of 6 are in backup mode.
Backing up control file to trace...
admindir = /u01/app/oracle/admin
udumpdir = /u01/app/oracle/admin/testdb/udump
Database altered.
a /u01/app/oracle/admin/testdb/udump/testdb_lgwr_11077.trc 6K
a /u01/app/oracle/admin/testdb/udump/testdb_ora_19457.trc 2K
a /u01/app/oracle/admin/testdb/udump/testdb_ora_27106.trc 4K
Switching logfile...
System altered.

Copying logs to arch_hold...
Cleaning up old logs in arch_hold
Attempting to tar files created during the hot backup ...
oracle >pwd
/u01/app/oracle/backup/usadc-0001/log

bold marked timestamp i need to capture

appreciated your help
Thanks
Prakash

---------- Post updated at 11:41 PM ---------- Previous update was at 11:40 PM ----------

any sample script for this please
# 6  
Old 11-11-2010
Hi,

Try this
Code:
#!/bin/sh

i=1
for i in {1..40}
do
  j=$i
  if [ $j -lt 10 ]; then j="0"$i; fi
  cd /u01/app/oracle/backup/usadc"$j" && cd log
  k=1
  ls *.* | sort | grep "\(begin\|end\)$" | while read file
  do
        p=$(expr $k % 2)
        if [ $p == 0 ]; then
        res=$(perl -nle 'if(/(\d+\/\d+\/\d+-\d+:\d+:\d+).*(Beginning|Finishing)/) {print $1;}' $file1 $file)
        new_file=$(echo $file1 | awk -F"." '{print $1}')
        echo "$res" > $new_file".NEW"
        else
        file1=$file
        fi
        k=$(expr $k + 1)
   done
done

# 7  
Old 11-11-2010
Hi,

i got this error

oracle >sh test.sh
test.sh: syntax error at line 12: `p=$' unexpected


can you help me further please

Thanks
Prakash
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Script that automatically generates HTML

hi I have a script with HTML code and am currently generating the html page everytime using genWebsite.sh > startPage.html Is it possible to have a loop at the begining of the script to run this command every minute so an updated HTML page is displayed or could someone suggest an alternative... (2 Replies)
Discussion started by: scriptnewbie
2 Replies

2. UNIX for Dummies Questions & Answers

I need perl script on cold backup in Oracle 10 g

Hi , I am new to Perl script.Can u please provide me perl scripts for the following: 1. Perl script on Cold backup in Oracle 10g 2.Perl script on Hot backup in Oracle 10g (0 Replies)
Discussion started by: Niharika Srivas
0 Replies

3. Shell Programming and Scripting

Report generation using perl script

Hi, I have a perl script to read the log file and create a report from it. I have the script file and log file in a different directories. Now i have pipe the log file data to the perl script to create the report (HMTL file). I am using the below command this isn't working tail -f... (4 Replies)
Discussion started by: vel4ever
4 Replies

4. Shell Programming and Scripting

Print one's place for 1 to N times, ksh Perl whatever?

Hello all, I would like to create a for loop or whatever is quick that will print the one’s place of a number for 1-N times say for example a printed page formatting is 132 characters wide, I would like a single line 123456789012345678901234567890... ...012 That is 132 characters long. I... (11 Replies)
Discussion started by: KmJohnson
11 Replies

5. Shell Programming and Scripting

Help in modifying existing Perl Script to produce report of dupes

Hello, I have a large amount of data with the following structure: Word=Transliterated word I have written a Perl Script (reproduced below) which goes through the full file and identifies all dupes on the right hand side. It creates successfully a new file with two headers: Singletons and Dupes.... (5 Replies)
Discussion started by: gimley
5 Replies

6. Solaris

How to find out the script which generates the file in solaris/unix ?

Hi A file is generated/created/modified during installation (or) execution of a script. vice versa..How to find out which script is responsible for creating/modifying a file. Example:- ....An existing file ( hosts.ulcm ), this file is created or modified by running a script ( may be... (1 Reply)
Discussion started by: frintocf
1 Replies

7. Shell Programming and Scripting

Help with perl mysql backup script

Hi, im trying to make a script that backups mysql databases but apparently I am having trouble with the variables, or simply something I am missing. Would appreciate any help, here is the script #!/usr/bin/perl -w use strict; require File::Spec; #VARIABLES my $databasename =... (4 Replies)
Discussion started by: Fireline
4 Replies

8. UNIX for Advanced & Expert Users

A Program Which Generates a Script Which Kills It

I have a C++ program, running on Fedora Linux, which has to be able to update itself to a new version, which it can obtain from a server. The way I do this is to have it create a shell script which kills it (the parent process), uninstalls it, downloads the new version (actually it does this... (1 Reply)
Discussion started by: BrandonShw
1 Replies

9. Shell Programming and Scripting

backup report script

Hi , Let me know how to write a script that runs a <a backup command> to check the backups of a particular client from the last_night & today' dates and print the out. (2 Replies)
Discussion started by: new2prog
2 Replies
Login or Register to Ask a Question