Friday 19 January 2018

Showing progress of BackupPC backup while it is happening

I have just finished upgrading my central linux gateway box from ClearOs 6 to 7. I took the opportunity to do a complete rebuild, and evaluate what apps I run on it.

I discovered BackupPC is a free option in the ClearOs Marketplace, so decided to try it, as the application I used before, CrashPlan, is no longer free.

It is quite handy, once you have understood how to configure it. I now have it set up to backup the gateway box itself, plus all my PCs. It keeps 3 weeks backups of essential files on a twice-daily basis, so I should be able to recover any version of any file for any day up to 3 weeks ago.

While setting it up, I wanted to monitor the progress of my initial backups, to make sure they were doing what I wanted. Unfortunately, BackupPC does not support this out of the box. The backup log is kept in a compressed file, in a slightly non-standard format.

However, with the aid of a little research, I found the file was just missing the gzip header, so was able to devise a shell script which would show me the log output (almost) as it happened.

Here is the script - call it with the name of the host being backed up, and it will tail the log file continuously.

#! /bin/bash
# Show progress of BackupPC backup
cd /var/lib/BackupPC/pc/$1
(printf "\x1f\x8b\x08\x00\x00\x00\x00\x00" ; tail -f -c+0 XferLOG.z) | gzip -dc | tail -f