Networking

Unix and Linux network configuration. Multiple network interfaces. Bridged NICs. High-availability network configurations.

Applications

Reviews of latest Unix and Linux software. Helpful tips for application support admins. Automating application support.

Data

Disk partitioning, filesystems, directories, and files. Volume management, logical volumes, HA filesystems. Backups and disaster recovery.

Monitoring

Distributed server monitoring. Server performance and capacity planning. Monitoring applications, network status and user activity.

Commands & Shells

Cool Unix shell commands and options. Command-line tools and application. Things every Unix sysadmin needs to know.

Home » Backups, Scripts, Veritas

NetBackup statistics, Part I

Submitted by on November 21, 2005 – 4:59 pm 3 Comments

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

Print Friendly, PDF & Email

3 Comments »

  • Boo Cookie says:

    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?

  • Terrence says:

    I want to use Veritas Netbackup for My practice to Backup Oracle Database

  • _marky_mark_ says:

    I noticed the feature in Apache HTTP server for Windows but I need to know how the feature will be useful.

1 Pingbacks »

Leave a Reply

%d bloggers like this: