Menu Home

Getting backup progress at the CLI for Netbackup on Linux

So a client has a long running backup that tends to overrun when performed as a full backup. Incrementals are fine. Unfortunately, there’s little that I can do to fix it, as that’s a call for another team. However, it has been frustrating, having to login to a Windows server, use the Netbackup Admin Console to see how many kB have been transferred and then attempt to calculate the progress based on that. And Google searches for doing the same from the command line gave all sorts of cruddy advice.

Here’s what I have so far, it’s a bit raw but the logic can be built on.

$ pwd
/opt/openv/netbackup/bin/admincmd

Ok, showing the base path that I’m working in. Here we go:

$ printf "%s\n" "scale=2; $(./bpdbjobs -most_columns -jobid 2056979 | awk -F, '{print $15}')*100/$(df -kP /mnt/some/mountpoint/ | tail -1 | awk '{print $3}')" | bc
76.41

Explanation and showing my working:
If we don’t already know the jobid, we can grab it using bperror, looking for the policy and client. In this case I don’t know when the job was started, so I’m casting a bit wider and checking in the last 24 hours. This is a direct copy and paste from a real invocation of this command, but with the client sensitive information changed:

$ ./bperror -U -columns 400 -hoursago 24 | grep -i AwesomePolicy | grep thisHost
02/12/2016 18:09:12 netbackup.fqdn -  backup job submission request (jobid=2053918) for client thisHost.fqdn, policy AwesomePolicy, schedule cm_AwesomePolicy
02/12/2016 18:12:47 anotherHost thisHost.fqdn started backup job for client thisHost.fqdn, policy AwesomePolicy, schedule cm_AwesomePolicy on storage unit stu_dup_disk_anotherHost
02/13/2016 04:40:53 anotherHost thisHost.fqdn  CLIENT thisHost.fqdn  POLICY AwesomePolicy  SCHED cm_AwesomePolicy  EXIT STATUS 0 (the requested operation was successfully completed)
02/13/2016 04:59:01 netbackup.fqdn -  backup job submission request (jobid=2056979) for client thisHost.fqdn, policy AwesomePolicy, schedule cm_AwesomePolicy
02/13/2016 04:59:02 anotherHost thisHost.fqdn  started backup job for client thisHost.fqdn, policy AwesomePolicy, schedule cm_AwesomePolicy on storage unit stu_dup_disk_anotherHost

Ok, so chances are that the second jobid shown here is the one we want. We can then use bpdbjobs and -most_columns to get extra information in csv format. (-all_columns gives even more detail). Field 15 is “kbytes”, in other words how much has been backed up so far, so we awk that out.

$ ./bpdbjobs -most_columns -jobid 2056979
2056979,0,1,,AwesomePolicy,AwesomePolicy,thisHost.fqdn,anotherHost,1455292741,0000037645,0000000000,stu_dup_disk_anotherHost,1,3,382007552,10,/mnt/some/mountpoint/somefile.dat,0,15344,root,2,0,2,500,root,netbackup.fqdn,-1,-1,0,0,0,0,0,2056979,10190,,,,,,,,,,,0,0,0,1,0,0,thisHost.fqdn_1455292742,1,,0,0, ,,

(Reference for the list of fields: https://www.veritas.com/support/en_US/article.TECH65123 )

We also need to know the size of the backup. In this instance we’re assuming a full backup (because those are the ones we’re having issues with), so we can just go with the amount of filesystem usage on the filesystem being backed up. Using df -kP we force kByte output in portable format, then pluck out the field that we want:

$ df -kP /mnt/some/mountpoint/
Filesystem         1024-blocks      Used Available Capacity Mounted on
/dev/mapper/That-Secret-VG-LV 568699936 495222640  44590640      92% /mnt/some/mountpoint/

Ok, so now we know that we’ve transferred 382007552kB, and there’s a total of roughly 495222640kB to backup.

Then it’s a simple matter of $y*100/$x through bc to get a percentage. We opt to use bc rather than shell built-in maths for floating point arithmetic, which gives us two decimal places. I’ve found that, sometimes, Netbackup will sit at 99% for a while, so having the extra two digits gives better visibility that something is occurring.

And that’s really the guts of it. It should be possible to build a straightforward script based on this that gives a nicer output e.g.

Backup of /mnt/some/mountpoint is currently at 76.12%

Categories: Geeking Out Tech Tips

rawiri