MacOS – Send Wake-On-Lan packets from Mac to Nas for TimeMachine backups

macosnasNetwork

I have a NAS box that is "Wake On Lan" enabled. I'm struggling to find a way for to utilise this with my TimeMachine backups from my Mac (Mountain Lion).

My intention is that may Mac will wake the sleeping Nas when TimeMachine backups are scheduled.

Has anybody got any experience of sending magic packets from a mac to a nas? Any assistance would be greatly appreciated.

Cheers

Noel

Best Answer

I resolves this by the using an answer from this question that links to this blog post, and incorporating this Wake UP NAS applescript into the automator app (Changing the MAC and local broadcast IP address to suit)

Wake Up Nas Script:

do shell script "python -c \"
import socket
data = '\\xff'*6+'\\x00\\x13\\xd4\\xdc\\xf2\\x80'*16
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
s.sendto(data, ('192.168.1.255', 80))\""

The automator app is as follows:

pause 10 seconds
run the above WakeUpNas script
pause 4 mins (let the nas start up if needs be)
Get Specified Servers (add the servers that you want to wake)
Connect to Servers

Then adding the above App to the startup items to reconnect to drive when the Mac restarts.

By following the blog post you can also call the app when the computer wakes from sleep by installing Sleepwatcher and a little extra work.