cancel
Showing results for 
Search instead for 
Did you mean: 

script execution\parameters

reachah
Level 4

Hi,

I have a script which has the below content,

#!/bin/bash
clear
echo "Please enter date(MM/DD/YYYY): "
read a
bpimagelist -policy CBCV***_backup_rdbmco1-01 -d $a 00:00:00 -e $a 23:59:59 -U | egrep -v "KB|--------" | awk '{print "CBCV***_backup_rdbmco1-01" "     "$5}';
bpimagelist -policy CBCVARESB***_backup_rgamco1-02 -d $a 00:00:00 -e $a 23:59:59 -U | egrep -v "KB|--------" | awk '{print "CBCVARESB***_backup_rgamco1-02" "   "$5}';

Running the above script ask me to provide the date,which is normally the previous day\date and it gives either incremental\full which ever is configured on that particular day and in size 'KB' . Eg:- given below,

Please enter date(MM/DD/YYYY):
03/02/2015
CBCV***_backup_rdbmco1-01       809430621
CBCVARESB***_backup_rgamco1-02  1121940746

However I am in need of the below contents\parameters,

1) It should check entire one week i.e., from FRI - THU

2) It should give me the name of schedule i.e., either 'full' or 'incremental' with corresponding date

3) size displayed should be in 'GB' instead of 'KB'

Kindly assist as this a critical report for my project

1 ACCEPTED SOLUTION

Accepted Solutions

Andy_Welburn
Level 6

Tweak and tidy up something along the lines of:

clear
echo "Please enter start date(MM/DD/YY): \c"
read STDATE
echo "Please enter end date(MM/DD/YY): \c"
read ENDATE
echo "Please enter Policy: \c"
read POL
bpimagelist -policy $POL -d $STDATE 00:00:00 -e $ENDATE 23:59:59 | grep IMAGE > /tmp/image
cat /tmp/image | while read LINE
do
SCHED=`echo $LINE | awk '{print $11}'`
SIZE=`echo $LINE | awk '{print $19}'`
CDATE=`echo $LINE | awk '{print $14}'`
DATE=`bpdbm -ctime $CDATE | cut -c14-`
SIZE=`expr $SIZE / 1024 / 1024`
echo "$DATE\t\t$SIZE\t\t$SCHED"
done

I notice that your OP included the output for two policies. So, if you wanted to run for more than one policy, you could loop the above for a (space de-limited) list of policies:

clear
echo "Please enter start date(MM/DD/YY): \c"
read STDATE
echo "Please enter end date(MM/DD/YY): \c"
read ENDATE
echo "Please enter (space de-limited) list of policies: \c"
read POL
for POLICY in $POL
do
echo $POLICY
bpimagelist -policy $POLICY -d $STDATE 00:00:00 -e $ENDATE 23:59:59 | grep IMAGE > /tmp/image
cat /tmp/image | while read LINE
do
SCHED=`echo $LINE | awk '{print $11}'`
SIZE=`echo $LINE | awk '{print $19}'`
CDATE=`echo $LINE | awk '{print $14}'`
DATE=`bpdbm -ctime $CDATE | cut -c14-`
SIZE=`expr $SIZE / 1024 / 1024`
echo "$DATE\t\t$SIZE\t\t$SCHED"
done
echo
done

View solution in original post

4 REPLIES 4

Marianne
Level 6
Partner    VIP    Accredited Certified

We have excellent script writers who should be able to help you change the input question to provide 2 dates as start and end-dates (-d and -e). 
You can also drop '-e $a 23:59:59' so that you just enter a start date. This will give you a report between start date and now.

Output with -U is very limited. To add more columns, you will need to replace -U with -l and then use awk to select the columns you want.

See this TN for 'bpimagelist -l' fields: http://www.symantec.com/docs/TECH5584 

Hope someone else can help with rest of your requirements.

Andy_Welburn
Level 6

Tweak and tidy up something along the lines of:

clear
echo "Please enter start date(MM/DD/YY): \c"
read STDATE
echo "Please enter end date(MM/DD/YY): \c"
read ENDATE
echo "Please enter Policy: \c"
read POL
bpimagelist -policy $POL -d $STDATE 00:00:00 -e $ENDATE 23:59:59 | grep IMAGE > /tmp/image
cat /tmp/image | while read LINE
do
SCHED=`echo $LINE | awk '{print $11}'`
SIZE=`echo $LINE | awk '{print $19}'`
CDATE=`echo $LINE | awk '{print $14}'`
DATE=`bpdbm -ctime $CDATE | cut -c14-`
SIZE=`expr $SIZE / 1024 / 1024`
echo "$DATE\t\t$SIZE\t\t$SCHED"
done

I notice that your OP included the output for two policies. So, if you wanted to run for more than one policy, you could loop the above for a (space de-limited) list of policies:

clear
echo "Please enter start date(MM/DD/YY): \c"
read STDATE
echo "Please enter end date(MM/DD/YY): \c"
read ENDATE
echo "Please enter (space de-limited) list of policies: \c"
read POL
for POLICY in $POL
do
echo $POLICY
bpimagelist -policy $POLICY -d $STDATE 00:00:00 -e $ENDATE 23:59:59 | grep IMAGE > /tmp/image
cat /tmp/image | while read LINE
do
SCHED=`echo $LINE | awk '{print $11}'`
SIZE=`echo $LINE | awk '{print $19}'`
CDATE=`echo $LINE | awk '{print $14}'`
DATE=`bpdbm -ctime $CDATE | cut -c14-`
SIZE=`expr $SIZE / 1024 / 1024`
echo "$DATE\t\t$SIZE\t\t$SCHED"
done
echo
done

reachah
Level 4

@MArianne : Thanks for the response

@Andy : Thanks for the inputs ,I had modified as you had suggested and below is the o/p I got :-

Please enter start date(MM/DD/YYYY): \c
03/04/2015
Please enter end date(MM/DD/YY): \c
03/11/2015
Please enter Policy: \c
CBCV_SIA_xxx2_backup_ldsia
Tue Mar 10 09:03:14 2015\t\t0\t\tIncremental
Tue Mar 10 09:03:13 2015\t\t1\t\tIncremental
Mon Mar  9 09:03:15 2015\t\t0\t\tIncremental
Mon Mar  9 09:03:14 2015\t\t1\t\tIncremental
Sun Mar  8 09:03:17 2015\t\t0\t\tIncremental
Sun Mar  8 09:03:16 2015\t\t1\t\tIncremental
Sat Mar  7 09:03:29 2015\t\t0\t\tIncremental
Sat Mar  7 09:03:28 2015\t\t1\t\tIncremental
Fri Mar  6 09:03:31 2015\t\t0\t\tIncremental
Fri Mar  6 09:03:30 2015\t\t1\t\tIncremental
Thu Mar  5 09:03:07 2015\t\t0\t\tIncremental
Thu Mar  5 09:03:06 2015\t\t1\t\tIncremental
Wed Mar  4 09:02:56 2015\t\t0\t\tFull
Wed Mar  4 09:02:55 2015\t\t1\t\tFull

Then I tried '#'out the lines i.e., # | grep IMAGE > /tmp/image. and adding '-U' in the line i.e., as below

bpimagelist -policy $POL -d $STDATE 00:00:00 -e $ENDATE 23:59:59 -U
# | grep IMAGE > /tmp/image

Now I got the required output .

1) However I still want the output only for 'FULL' backups(no incrementals) .Is it possible ?

2) Also I want to feed the scripts with Policy details ,instead of me providing it manually everytime . As I have around '50 policies in total .

Kindly suggest !!

Andy_Welburn
Level 6

I presume you're using 'bash' - doesn't seem to like the formatting options (i.e. prints out the \c & \t etc)

I used the "grep IMAGE" from the output as I was under the impression that you wanted the schedule name & that isn't included in the -U output

1) "However I still want the output only for 'FULL'" Still? You originally asked for "either 'full' or 'incremental' "     You could potentially ''grep -v INCR" to exclude incrementals if appropriate - EDIT this may not work, use the bpimagelist option -st FULL

2) loop it. Either create a file of all your policies (bppllist    - without options) or edit same & feed that into your script or use 'bppllist' directly for all policies.

e.g.

for POLICY in `bppllist`
do
blah blah blah
done
 

EDIT #2

clear
echo "Please enter start date(MM/DD/YY): \c"
read STDATE
echo "Please enter end date(MM/DD/YY): \c"
read ENDATE
for POLICY in `bppllist`
do
  echo $POLICY
  bpimagelist -policy $POLICY -st FULL -d $STDATE 00:00:00 -e $ENDATE 23:59:59 | grep IMAGE > /tmp/image
  cat /tmp/image | while read LINE
  do
      SCHED=`echo $LINE | awk '{print $11}'`
      SIZE=`echo $LINE | awk '{print $19}'`
      CDATE=`echo $LINE | awk '{print $14}'`
      DATE=`bpdbm -ctime $CDATE | cut -c14-`
      SIZE=`expr $SIZE / 1024 / 1024`
      echo "$DATE\t\t$SIZE\t\t$SCHED"
  done
  echo
done

which gives me something along the lines of:

# ./script

Please enter start date(MM/DD/YY): 02/01/15
Please enter end date(MM/DD/YY): 03/10/15
Andy_PC
no entity was found

ANOther_Policy
Sat Mar  7 10:00:04 2015                39              Weekly_SYNTH
Sat Feb 28 10:00:04 2015                47              Weekly_SYNTH
Sat Feb 21 10:00:03 2015                47              Weekly_SYNTH
Sat Feb 14 10:00:03 2015                47              Weekly_SYNTH
Sat Feb  7 10:00:05 2015                46              Weekly_SYNTH

And_Another_One
Sat Mar  7 08:00:01 2015                99              Weekly_FULL
Sat Feb 28 08:00:01 2015                99              Weekly_FULL
Sat Feb 21 08:00:01 2015                99              Weekly_FULL
Sat Feb 14 08:00:01 2015                99              Weekly_FULL
Sat Feb  7 08:00:01 2015                99              Weekly_FULL