In the meantime I needed a way to disable backups when my laptop was running on batteries, because the the external USB backup disk runs on mains power. This is easy enough using the script on_ac_power (part of the powermgmt-base package) - define the following function
# must be on AC power
echo -n "Checking AC Power ... "
( on_ac_power > /dev/null && ( echo "ON" ; return 0 ) ) || ( echo "OFF" ; return 1 )
and run it at the beginning of the script that's executed by Bacula with the RunBeforeJob directive:
check_ac_power || exit $?
The exit $? bit is used to return the status that was returned by check_ac_power, if it fails (i.e. non-zero status code), to Bacula.
[14 Jul. 2008] UPDATE: the on_ac_power script stopped working after a kernel upgrade... (I've also revised and fixed the contents of this entry).