This is the website of Abulsme Noibatno Itramne (also known as Sam Minter). Posts here are rare these days. For current stuff, follow me on Mastodon

Categories

Calendar

December 2024
S M T W T F S
1234567
891011121314
15161718192021
22232425262728
293031  

Getting Backblaze Statistics from the Command Line on a Mac

I’ve been trying to keep a little dashboard showing how well Backblaze is doing keeping up with backing up my primary system (a Mac). I’d been doing this by hand every once in awhile by just taking the numbers of files and MB left shown by their icon in the menu bar. But that was manual and tedious. I wanted to automate it. I Googled a number of times things like “Backblaze Command Line” to try to find a way to pull this info, but never found anything useful. I poked around a bit looking for relevant log files, but didn’t find them until tonight. I found what I needed, so I thought I’d post so that if anybody else is looking to do the same thing, when they Google, they will find the answer, rather than having to dig and find this from scratch. Of course this is just for the Macintosh version. I am sure there is something equivalent in their Windows software, but I don’t have a Windows machine, so I’m not going to be the one to find it there.

Anyway…

It turns out what you need is all in a nice little file:

/Library/Backblaze/bzdata/bzreports/bzstat_remainingbackup.xml

The contents are pretty straight forward:

<?xml version=”1.0″ encoding=”UTF-8″ ?>
<contents>
<remaining remainingnumfilesforbackup=”2414327″ remainingnumbytesforbackup=”459544254971″ />
</contents>

So, for remaining files needing to be backed up:

cat /Library/Backblaze/bzdata/bzreports/bzstat_remainingbackup.xml | grep remaining | cut -d \” -f 2

And for remaining bytes needing to be backed up:

cat /Library/Backblaze/bzdata/bzreports/bzstat_remainingbackup.xml | grep remaining | cut -d \” -f 4

I use these together in a quick little shell script that I run every few hours using cron:

#!/bin/bash
# Updates BackBlaze Stats
FCFILE=/Users/abulsme/Dev/MailCount/bbfiles.txt
MBFILE=/Users/abulsme/Dev/MailCount/bbmeg.txt
date “+%m/%d/%Y %H:%M:%S” | tr -d ‘\n’ >> $FCFILE
echo -ne ‘\t’ >> $FCFILE
cat /Library/Backblaze/bzdata/bzreports/bzstat_remainingbackup.xml | grep remaining | cut -d \” -f 2 >> $FCFILE
date “+%m/%d/%Y %H:%M:%S” | tr -d ‘\n’ >> $MBFILE
echo -ne ‘\t’ >> $MBFILE
cat /Library/Backblaze/bzdata/bzreports/bzstat_remainingbackup.xml | grep remaining | cut -d \” -f 4 >> $MBFILE

My actual script actually does one more thing to convert bytes to megabytes for my charts, but the above gets you the raw data. What you do with it after that depends on your application and what you are trying to do with this info.

For me, I’m generating dashboard charts:

Everything prior to 2010 Jun 10 was me grabbing data manually for the graph. June 10th forward is pulled automatically by the above.

Anyway, hope this ends up being helpful for anybody else wanting to programmatically monitor how well Backblaze is or is not keeping up.

Edit 2012 Jul 9 13:02 UTC: In recent versions of Backblaze, the path that contains the report has changed to /Library/Backblaze.bzpkg/bzdata/bzreports/ .