Netbackup Script to get Policy Vs client list

Here is a small script to get the list of clients configured against a list of policies in netbackup. Command used here is bpplclients to get the client list.

Put the list of policy in a file /tmp/policy_list.

# cat /tmp/policy_list
policy01
policy02
policy03

The script :

for i in `cat /tmp/policy_list`
do
    bpplclients $i -noheader | awk 'BEGIN {printf "'$i'"}{print "," $NF}'
done > /tmp/output.csv

Below is the Output file [ comma (,) separated ]

policy01,client01
,client02
policy02,client01
policy03,client01

The output CSV file should look like below :

Policy Name Clients
policy01 client01
client02
policy02 client01
policy03 client01

Output in

In the output shown above, Policy name is printed only once for multiple clients. To get the CSV file in the format where backup policy is printed on each line for every client, Use the below script :

for i in `cat /tmp/policy_list`
do
    bpplclients $i -noheader | awk '{printf "'$i'" "," $NF}'
done > /tmp/output.csv

Below is the Output file [ comma (,) separated ]

policy01,client01
policy01,client02
policy02,client01
policy03,client01

The output CSV file should look like below :

Policy Name Clients
policy01 client01
policy01 client02
policy02 client01
policy03 client01
Related Post