backuppc backups Linux magic packet wake on lan WOL

Backuppc and waking machines

In our office there are 9 machines, all of which are backed up nightly with Backuppc. However I did often notice that machines did not get backed up, usually because the machine was not turned on. This was becoming a problem and over half of the machines were not being backed up nightly and some had not been done for many weeks. The nagging e-mails that Backuppc sends out were also being ignored as well.

I needed a way to ensure the machines were on, at least when it was their turn to be backed up. Enter the linux program etherwake. Etherwake sends out a magic packed to a specific machine by it MAC address. Typically machines will not wake when they are pinged, only a specific so-called “magic packet” will wake a machine.

Backuppc does not however have anything currently builtin which invokes etherwake before attempting to wake it. It also has a habit of doing a nmblookup before backup as well, which will most likely fail if the machine has been off for some time.

What I did was replace the ping command in backuppc with a bash shell script and disable the nmblookup. Here’s how I did it.

First write a script in bash and place where you like. It will be someplace where the backuppc user will have rights to access to it. I put the script in the backuppc user’s home.


#this script is totally designed for the backuppc ping command
#which is the first thing it does before it starts a backup
#this is a substitute which pings the machine, if it is not
#awake then it wakes it using a magic packet - using the wol.bsh script
#then pings again to make sure


logger "Backuppc pinging $1 $2 $3"

function fwol {
sudo $ETHWAKE $1
if [ $? -eq 0 ]

$PING $ARG1 $ARG2 $WAKEHOST >>/dev/null 2>&1

if [ $? -ne 0 ]; then
if [ "$WOL_RES" = "FAIL" ]; then
exit 1
if [ $? -eq 0 ]
logger "success waking $WAKEHOST."
logger "unable to wake $WAKEHOST."
exit 1

exit 0

I saved this a wolping.bsh. Essentially this first checks if the machine is up by pinging it. If it does respond then it simply drops out and pings again. Otherwise it invokes etherwake, waits for three minutes and then ping again. Note that in the backuppc code it will invoke the ping command twice, the first time as a wakeup and second the check the roundtrip time. Which is why I first send the ping to /dev/null and then ping again, I don’t want the first output read by backuppc.

Now in backuppc in the server config, you will need to do the following:

  • Set PingPath to the path to where you saved the script above
  • Set NmbLookupFindHostCmd on Backup Settings to blank

Removing the NmbLookup will disable this “feature” and prevent backuppc from reporting the machine down before it wakes up.

That’s it for the backuppc configuration. There is one last item which is needed. Remember etherwake only understands MAC addresses, but backuppc is invoking our script with a host name. So how can you make a host name to a MAC address?

Etherwake will search a /etc/ethers file when it is given a host name. So create one, you’ll need to obtain the MAC addresses of all the machines you want to respond and add them into a ethers file as MAC hostname pairs, similar to a hosts file, eg:

00:3B:56:89:1A:22   myhost

And that’s all there is to it. I now even have the backup server woken up by the router when needed. There is no reason to have any more machines on than necessary.

Next post I’ll get into how you set this up on Linux and Windows to respond to these WOL/magic packet requests.