Netbackup Scripts – clean-jobs

NetbackupFar too many jobs end up in the Java GUI or in the bpdbjobs output… If the job is successful, why does it stick around for three days. This hides the real problems that may have occurred.

My solution is a cron job that deletes successful jobs (Status Code of 0 and 1).


use strict;

my $jobid; my $type; my $state; my $status; my $policy;
my $sched; my $client; my $media_server; my $pid; my @jobs;
my $delete_string;

my $cmd='/usr/openv/netbackup/bin/admincmd/bpdbjobs';
chomp(my @output=`$cmd`);
shift @output; # Skip the header record..

foreach (@output)
s/Image Delete/Image_Delete/;
($jobid, $type, $state, $status, $policy, $sched, $client, $media_server, $pid) = split (" ",$_);
 if (( $state eq "Done") && (SafeCode($status)==0)) {
 push @jobs, $jobid;

$delete_string = shift @jobs;
foreach (@jobs) {
 $delete_string .= ",";

if (defined($delete_string)) {
 `$cmd -delete $delete_string`


sub SafeCode {
 my $query = @_[0];
 my @safecodes = qw / 0 1 /;
 foreach (@safecodes) {
 if ( $query == $_ ) {
 return 0;
 return -1;

Netbackup jobs that won’t go away..

Occasionally, you get a job in the queue that you can’t cancel/delete through the GUI nor through command line…   Here is the solution to that..

• Note the JobID from bpdbjobs
• Stop Netbackup with bp.kill_all
• /usr/openv/netbackup/bin/bpjobd –r {JobID}
• Restart Netbackup with /etc/init.d/netbackup start

The following thread discusses different attempts at solving th this issue, with this process being the final solution.

Netbackup Scripts – client-last-backup

Quick report on the last backup for a client of your choice..

(Your mileage may vary with this one… I made some assumptions along the way that reflect my environment… But you can always use it as a starting point for your own version…)


[ $# != 1 ] &&
    echo "Usage: $0 {CLIENT_NAME}" &&
    exit 99

    -allunique -noheader | awk '{print $NF}' |
    grep ${CLIENT} > /dev/null
[ $? -ne 0 ] &&
    echo "Error: ${CLIENT} is not a valid client." &&
    exit 99

TMP_FILE=/tmp/`basename $0`.${PPID}
bperror -client ${CLIENT} > ${TMP_FILE}

JOBID=`grep "nbjm started backup job" ${TMP_FILE} |
    egrep -v "oracle|catalog|DSSU" |tail -1 |awk '{print $7}'`

TYPE=`grep ${JOBID} ${TMP_FILE} |
    grep "nbjm started backup job" |
    tail -1 | awk '{print $20}'`

START=`grep ${JOBID} ${TMP_FILE} |head -1 |awk '{print $1}'`
START_PRETTY=`bpdbm -ctime ${START} |cut -c18-`

FINISH=`grep ${JOBID} ${TMP_FILE} |tail -1 |awk '{print $1}'`
FINISH_PRETTY=`bpdbm -ctime ${FINISH} |cut -c18-`

    grep "successfully wrote backup" |
    wc -l | sed 's/ //g'`

for SIZE in `grep ${JOBID} ${TMP_FILE} |
    grep "bptm successfully wrote backup" |
    awk '{print $20}' `

if [ ${TOTAL_SIZE} -ge 10000 ];

if [ ${TOTAL_SIZE} -ge 10000 ];

echo " Client: ${CLIENT} "
echo " Start: ${START_PRETTY}"
echo " Finish: ${FINISH_PRETTY}"
echo " Backup Type: ${TYPE}"
echo " Backup Size: ${TOTAL_SIZE} ${SIZE_UNIT}"
echo " Job Count: ${JOB_COUNT}"
echo " File Systems/Volumes:"
for FILE_SYSTEM in `grep ${JOBID} ${TMP_FILE} |
    grep "handling path" |
    sed 's/Shadow Copy Components/Shadow_Copy_Components/' |
    grep -v "SNAP_ID" | awk '{print $NF}' | sort `
    echo ${FILE_SYSTEM} | grep MNTPOINT > /dev/null
    if [ $? -eq 0 ]; then
        FILE_SYSTEM=`echo ${FILE_SYSTEM} |
            awk -F"=" '{print $3}' |
            awk -F"," '{print $1}'`
    echo "    ${FILE_SYSTEM}"

rm -f ${TMP_FILE}

exit 0

And the output…

Client: xxxxx
 Start: Aug 30 18:01:21 2012
 Finish: Aug 30 18:07:41 2012
 Backup Type: Incremental_Backup
 Backup Size: 1380 MB
 Job Count: 5
 File Systems/Volumes:

Netbackup via Command Line…

I live in a Unix Shell… Nothing that bothers me more than to have to launch a big heavy GUI to find out something simple..

Here are a couple of Netbackup scripts that I make use of on a daily basis to avoid the Java GUI..

client-list:  Lists clients currently backed up.

    -allunique -noheader  | awk '{print $NF}'

Netbackup Client Uninstall in Solaris

As far as I can tell, Veritas does not provide an uninstall script to remove the Netbackup 6.0 Client from Solaris 10 Servers…

I went looking to see what files the client installed, and what  services were started up, and based on that here is my best guess as to how to cleanly remove the client.

svcadm disable network/bpcd/tcp
svccfg delete network/bpcd/tcp

svcadm disable network/vnetd/tcp
svccfg delete network/vnetd/tcp

svcadm disable network/vopied/tcp
svccfg delete network/vopied/tcp

svcadm disable network/bpjava-msvc/tcp
svccfg delete network/bpjava-msvc/tcp

cd /var/svc/manifest/network
rm bpcd-tcp.xml vnetd-tcp.xml vopied-tcp.xml

vi /etc/inetd.conf
(Remove bpcd vnetd vopied & bpjava-msvc)

vi /etc/services
(Remove bprd bpcd vnetd vopied & bpjava-msvc)

pkill –HUP inetd

rm –rf /usr/openv
(Make sure you're not dealing with file system first..)