Running Bacula bconsole Commands from bash CLI

Greetings, Traveler.

So if you’re one of the types who use Bacula as your backup server, you’re probably familiar with the ‘bconsole’ command line utility.  I prefer using this to the Bacula Admin Tool (BAT) because it’s faster.

The neat thing is that you can pipe commands right to bconsole to get immediate output from Bacula:

vmhacks.com]# echo "status dir" | bconsole

Connecting to Director localhost:9101
1000 OK: bacula-dir Version: 5.0.0 (26 January 2010)
Enter a period to cancel a command.
status dir
bacula-dir Version: 5.0.0 (26 January 2010) x86_64-redhat-linux-gnu redhat

Your output of that command will also spit out all your job info.

Ok let’s say you’re running a job and you want to get how many bytes have been backed up so far.  (Note: If you have more than one storage device configured, you’ll need to add a number output to select the storage):

vmhacks.com]# echo "status storage" | bconsole | grep Bytes | head -n1

If you want to just see the numbers go up without any intervention, you can throw watch in front of the above to get an auto updated listing of the amount backed up so far:

vmhacks.com]#  watch -n 1 'echo "status storage" | bconsole | grep Bytes | head -n1'

Every 1.0s: echo “status storage” | bconsole | grep Bytes | head -n1
Files=19,943 Bytes=11,286,167,448 Bytes/sec=8,755,754\

Of course, this can be used for all sorts of wacky Bacula fun! Go nuts.

Mm.,