Creating Backup Report 
Author Message
 Creating Backup Report


Quote:

>Greeting,
>I'm trying to creat a tape summary report from a dumplog thats
>created during my nightly backup operations:

>DUMPLOG FORAMT: tape#,date,filesystems:
>111 01/01/98 /apps
>......
>.....
>111 07/21/98 /apps

>OUTPUT DESIRED:
>Tape-num:   Num-of-times-used:      (Bonus)Last Date used:
>==============================================================
>111               2                      07/21/98

>CURRENT MODEL:(from SED & AWK O'Reilly .):

>!#/bin/ksh
>gawk `$1==/[0-9]/{print $1","$2}' $* |

>sort |

>$1 == lastTape { print "\t" $2 }
>$1 != LastTape { LastTape =$1; print $1; print "\t" $2}

use gawk's array capability.

#!/bin/sh
echo "Tape-num:      Num-of-times-used:      (Bonus)Last Date used:"
echo "=============================================================="
tr '/' " " < infile |sort -n +3 -4 +1 -2 +2 -3 |
gawk '{t[$1]=$1;cnt[$1]++;date[$1]=$2"/"$3"/"$4}END{for (i in t){
       print t[i],"\t\t\t",cnt[i],"\t\t\t"date[i]}}' |sort -n
# end of script

Adjust spacing as required, or use printf and format as desired.

for this data:

111 01/01/98 /apps
111 07/21/97 /apps
112 01/01/98 /apps
112 07/21/98 /apps
112 07/20/98 /apps
110 07/21/98 /apps
110 06/21/98 /apps

The script produced this output:

Tape-num:      Num-of-times-used:      (Bonus)Last Date used:
==============================================================
110                      2                      07/21/98
111                      2                      01/01/98
112                      3                      07/21/98

man grep
man sort

Chuck Demas
Needham, Mass.

--
  Eat Healthy    |   _ _   | Nothing would be done at all,

  Die Anyway     |    v    | That no one could find fault with it.



Sun, 14 Jan 2001 03:00:00 GMT  
 Creating Backup Report

% I'm trying to creat a tape summary report from a dumplog thats
% created during my nightly backup operations:
%
% DUMPLOG FORAMT: tape#,date,filesystems:
% 111 01/01/98 /apps
% ......
% .....
% 111 07/21/98 /apps
%
% OUTPUT DESIRED:
% Tape-num:     Num-of-times-used:      (Bonus)Last Date used:
% ==============================================================
% 111               2                      07/21/98

You need to use arrays:

  # this runs for every row
  {
    uses[$1]++           # count uses of the tape
    lastTape[$1] = $2    # assuming the log is in sequential time order
  }
  END {
    print "Tape-num:\tNum-of-times-used:\t(Bonus)Last Date used:"
    print ""
    for (tape in uses) {
      print tape "\t\t" uses[tape] "\t\t\t" lastTape[tape] | "sort -n"
    }
    close("sort -n")
  }

The "sort -n" is just to get the output in tape-number order
--

Patrick TJ McPhee
East York  Canada



Sun, 14 Jan 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Creating Backup File(s)

2. Whe archive backup file create from browde database

3. CD Backups create read only files

4. Creating Diskette Backup of Large DBF

5. create backup script in python

6. SetTarget(report) and Report$Feq{prop:create}

7. Reports created with the report writer

8. Creating a report from 2 files

9. Creating reports

10. Q:how can i create a report that can show records deleted for each table

11. Creating a temporary file for reports

12. Creating Report?

 

 
Powered by phpBB® Forum Software