Use Time Machine with Wake on LAN to Enable Network Backups to Sleeping Devices
**Update Sept 6, 2009: **I’ve created a project at github to simplify this process. More details here.
Task: You want to use Time Machine wirelessly to backup your Mac to a drive on another Mac on your network.
Problem: If the target machine is in “sleep” mode, your backup will fail.
Solution: Send a “magic packet” to the target machine to wake it up if it’s sleeping.
Gotcha: New Macs support WOL via Airport. However if you’re using an older Mac, the target machine must be connected via ethernet (the machine you’re backing up can still be connected via wifi).
Let’s roll:
Prep the Target Machine
The target machine is the Mac that will hold your backups.
-
On the target machine, go to System Preferences and open the “Energy Saver” panel.
-
Configure sleep settings as desired
-
Be sure to check the “Wake for Ethernet network access” box at the bottom.
-
Close out of system preferences.
-
Open System Profiler from your Utilities directory in Applications.
-
Click “Network” in the left panel.
-
Click “Ethernet” in the top panel.
-
In the bottom panel, scroll down until you see “Ethernet:” with a line under it showing something like “MAC Address 00:15:d4:a3:cf:1b”. Write down this 12-digit MAC address.
-
Exit System Profiler
Configure the Host Machine
The host machine is the Mac that you will be backing up.
-
On the host machine, install MacPorts if you haven’t already.
-
Open up a Terminal from your Utilities directory in Applications.
-
Type: “sudo port install wakeonlan” and press return.
-
Enter your password when prompted, and wait while MacPorts installs the utility and its dependencies.
-
Open Automator in Applications.
-
Create a new “Application” workflow when prompted.
-
Double-click the “Run Shell Script” library item on the left. In the box that appears, erase “cat” and instead type:
macaddress="00:00:00:00:00:00" while true do results=`syslog -k Sender com.apple.backupd -k Time gt -10s -k Message Seq 'Starting standard backup'` if [ -n "$results" ] then /opt/local/bin/wakeonlan "$macaddress" while [ -n "$results" ] do sleep 10 results=`syslog -k Sender com.apple.backupd -k Time gt -10s -k Message Seq 'Starting standard backup'` done fi sleep 10 done
-
In the first line, replace the 00:00:00:00:00:00 with the MAC Address that you wrote down earlier. Be sure to keep the quotes.
-
Choose File > Save As…, and name it “WOL Daemon” in the Applications folder when prompted.
-
Exit Automator.
-
Go to System Preferences and open the “Accounts” panel.
-
Click “Login Items” at the top.
-
Click the + icon to add a new one.
-
Select the WOL Daemon that you just created, and check the box next to it marked “Hide”.
-
Restart your computer, and voilà, your target machine will now be woken up if it’s asleep while Time Machine runs.