Important: I back up to a time capsule, via wifi.

  • I set my computer up to automatically wake up at 2:58 AM.
  • At 2:59 AM I run a script that launches "caffeinate -s", in order to prevent my MacBook to go back to sleep.
  • At 3:00 AM I run a scheduled Time Machine backup - Time Machine itself is turned off in the settings, though.
  • I run another script that kills caffeinate when the backupd process is gone, so my Mac can go back to sleep.

My goal: Only run backups at night, when I usually do not use my MacBook.

What happens: - When I make the Mac sleep, but have the lid open, it works as I'd like it. - When I make the Mac sleep by closing the lid, it doesn't work. Time Machine can't find the backup device.

This is the caffeinate script. backupd is launched with TimeMachineScheduler.

/usr/bin/caffeinate -s &
while [ ! "$(pidof backupd)" ]; do
        sleep 10
while [ "$(pidof backupd)" ]; do
/usr/bin/pkill caffeinate
  • This may be the answer, but I'll start with a comment. Do you meet the requirements for your Mac to work in clamshell mode? support.apple.com/kb/HT3131 If not, this will turn into how to defeat clamshell sleep since the setup looks fine as described.
    – bmike
    Jan 27 '13 at 15:03
  • I have a MacBook5,1, so it should work. Do you mean I should attach an external keyboard / mouse / display? Jan 27 '13 at 17:06
  • Yes - the Mac is designed to go to sleep when the lid is closed. The only exception is those models that are designed to run in clamshell mode. Connecting a video adapter is usually all that is needed, but a full monitor connected would also work (and it would power on while the Mac woke up to do your backup).
    – bmike
    Jan 27 '13 at 20:07
  • 1
    The mac does wake up for the backup though, and it does stay awake until caffeinate is killed. It just never seems to be able to find my Time Capsule, sadly. Maybe the WiFi does not wake up in clamshell mode. I should just try to attach a monitor then and see if that helps. But that's not a solution I am happy with. I'd just like to park my MacBook somewhere, and have it work. But I'll gladly mark your answer as correct. Thanks! Jan 28 '13 at 9:16
  • 2
    I observed a behavior that obviously changed from Lion => Mountain Lion: When my computer decides it's time for the monitor to sleep, the WiFi sleeps too. Usually that was not the case before. I suppose that I can create a little tool (or maybe even do it with Caffeinate) that creates a Power Assertion for WiFi. Jan 29 '13 at 7:54

You must log in to answer this question.

Browse other questions tagged .