0

Hello everyone,

Given a list of output that looks like this (from NetBackup bpimagelist if any of you are familiar), I need to pick out the last full backup closest to the end of the quarter (3/30, 6/30, 9/30 12/31).

10/20/2006 21:24 INFINITY 146144 64213523 N Full Backup
10/13/2006 21:46 INFINITY 144120 60868157 N Full Backup
10/06/2006 21:22 INFINITY 148940 59931237 N Full Backup
09/23/2006 02:14 INFINITY 114239 57878059 N Full Backup
09/15/2006 21:31 INFINITY 137821 58463789 N Full Backup
09/01/2006 23:47 INFINITY 130842 57890925 N Full Backup
08/25/2006 21:34 INFINITY 120475 57706942 N Full Backup
08/11/2006 22:49 INFINITY 105830 54603266 N Full Backup
06/28/2006 23:37 INFINITY 110950 45103754 N Full Backup

In the example above, I would want to pull out the 6/28 and 9/23 backups.

I appreciate any help!

2
Contributors
1
Reply
2
Views
9 Years
Discussion Span
Last Post by jim mcnamara
0

try:

#!/bin/ksh

export infile=filename
filedate()
{
	perl -e '
      use Time::Local;
      $mytime = timelocal(0,$ARGV[4],$ARGV[3],$ARGV[1],
                          $ARGV[0] - 1,$ARGV[2] - 1900);
      print "$mytime\n";
        ' $1 $2 $3 $4 $5
}


compare()
{
	keep="None found"
	maxallowed=$1
	minallowed=$2
	result=$minallowed
	while read record
	do
		echo "$record" | tr -s '/' ' ' | tr -s ':' ' '| \
		    read mon day yr hr mins dummy
		filedate $mon $day $yr $hr $mins | read value
		if [[ $value -lt $minallowed || $value -gt $maxallowed ]] ; then
		   continue
		fi   
		if [[ $value -gt $result ]] ; then
		     result=$value
		     keep=$record
		fi     
	done < $infile	
	print "$keep"
}

# Q1
filedate 12 31 2005 23 59 | read min
let min=$min+61
filedate 03 30 2006 23 59 | read limit
compare $limit  $min

#q2
let min=$limit+61
filedate 06 30 2006 23 59 | read limit
compare $limit  $min

#q3
let min=$limit+61
filedate 09 30 2006 23 59 | read limit
compare $limit $min

#q4
let min=$limit+61
filedate 12 31 2006 23 59 | read limit
compare $limit $min

input file:

10/20/2006 21:24 INFINITY 146144 64213523 N Full Backup
10/13/2006 21:46 INFINITY 144120 60868157 N Full Backup
10/06/2006 21:22 INFINITY 148940 59931237 N Full Backup
09/23/2006 02:14 INFINITY 114239 57878059 N Full Backup
09/15/2006 21:31 INFINITY 137821 58463789 N Full Backup
09/01/2006 23:47 INFINITY 130842 57890925 N Full Backup
08/25/2006 21:34 INFINITY 120475 57706942 N Full Backup
08/11/2006 22:49 INFINITY 105830 54603266 N Full Backup
06/28/2006 23:37 INFINITY 110950 45103754 N Full Backup

output:

kcsdev:/home/jmcnama> closest.sh
None found
06/28/2006 23:37 INFINITY 110950 45103754 N Full Backup
09/23/2006 02:14 INFINITY 114239 57878059 N Full Backup
10/20/2006 21:24 INFINITY 146144 64213523 N Full Backup
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.