NetBackup statistics, Part I
The following script will calculate total size of data backups for each Veritas NetBackup client over the past week (or as defined by the “daysago” variable in the script). The final output will be uploaded to a Web server. The output format is: clientname,backup_size_Gb
#!/bin/ksh
#
# ---------------------------------
# Set variables
# ---------------------------------
daysago=7
(( hoursago = daysago * 24 ))
# ---------------------------------
# Archive old output files
# ---------------------------------
if [ -r /var/adm/bin/bpstat/*_cron.txt ]
then
if [ ! -d /var/adm/bin/bpstat/backups/`date '+%m%d%y'` ]
then
mkdir /var/adm/bin/bpstat/backups/`date '+%m%d%y'`
else
rm /var/adm/bin/bpstat/backups/`date '+%m%d%y'`/*
fi
mv /var/adm/bin/bpstat/*_cron.txt /var/adm/bin/bpstat/backups/`date '+%m%d%y'`/
/usr/local/bin/gzip -r /var/adm/bin/bpstat/backups/`date '+%m%d%y'`/
fi
# ---------------------------------
# Manage archived files
# ---------------------------------
retain_weeks=25
if [ `ls /var/adm/bin/bpstat/backups/ | wc -l` -gt $retain_weeks ]
then
count=`ls /var/adm/bin/bpstat/backups/ | wc -l`
(( countrm = count - retain_weeks ))
countrm=`echo "-$countrm"`
ls /var/adm/bin/bpstat/backups/ | tail -r | tail $countrm | while read line
do
rm -r "$line"
done
fi
# ---------------------------------
# Extract list of NetBackup clients
# ---------------------------------
/usr/openv/netbackup/bin/admincmd/bpclclients -allunique -noheader | awk '{print $3}' > /var/adm/bin/bpstat/bpclients_cron.txt
# ---------------------------------
# Obtain NetBackup stats for the client list
# ---------------------------------
cat /var/adm/bin/bpstat/bpclients_cron.txt | while read line
do
/usr/openv/netbackup/bin/admincmd/bpimagelist -hoursago $hoursago -U -client $line | egrep "Full|User|Differential" | fgrep -v "Sched Type" | fgrep -ve "--" | while read line2
do
currentkb=$(echo $line2 | awk '{print $5}')
echo $line" "$currentkb >> /var/adm/bin/bpstat/nb2_cron.txt
done
done
cat /var/adm/bin/bpstat/nb2_cron.txt | sort > /var/adm/bin/bpstat/temp_02.txt
mv /var/adm/bin/bpstat/temp_02.txt /var/adm/bin/bpstat/nb2_cron.txt
# ---------------------------------
# Process nb2_cron.txt
# ---------------------------------
i=10000000000000000000
cat /var/adm/bin/bpstat/nb2_cron.txt | while read line
do
currenthost=$(echo $line | awk '{print $1}')
if [ $i -ne 10000000000000000000 ]
then
if [ "$currenthost" = "$prevhost" ]
then
currentsize=$(echo $line | awk '{print $2}')
(( i = i + currentsize ))
else
i=$(echo $i | awk '{ num = $1; gb = num / 1024 / 1024; print gb }')
echo $prevhost","$i >> /var/adm/bin/bpstat/final_output_cron.txt
echo $prevhost","$i
i=$(echo $line | awk '{print $2}')
prevhost=$currenthost
fi
else
prevhost=$currenthost
i=$(echo $line | awk '{print $2}')
fi
done
total=0
cat /var/adm/bin/bpstat/final_output_cron.txt | awk -F',' '{print $2}' | while read line
do
(( total = total + line ))
done
echo "ZZTOTAL for $daysago days [Gb],$total" >> /var/adm/bin/bpstat/final_output_cron.txt
mv /var/adm/bin/bpstat/final_output_cron.txt /var/adm/bin/bpstat/final_output.txt
chmod 777 /var/adm/bin/bpstat/final_output.txt
cd /var/adm/bin/bpstat
ftp -in webserver << bye
user username password
cd /var/apache/htdocs/bpstat
put final_output.txt
bye
mv /var/adm/bin/bpstat/final_output.txt /var/adm/bin/bpstat/final_output_cron.txt
3 Comments »
1 Pingbacks »
-
[…] This script uses the output of the script in the previous example to calculate yearly backup load for each NetBackup client. […]

How can I join the army, and be the gunner of an apache or similar gunship. What courses, do I need previous training, and where could I sign up?
Edit: I meant for America IF we go to war with them,
Apache means like a Chopper gunner not a sniper. Cause I bet everyone wants to be one because they don’t get shot at/die as much, so I’m wondering if you have to go through more training?
I want to use Veritas Netbackup for My practice to Backup Oracle Database
I noticed the feature in Apache HTTP server for Windows but I need to know how the feature will be useful.