Fixing Sierra’s Time Machine + bug: does macOS get overtired?

We know what overtired kids are like. If they don’t get to sleep when they need to, even the most well-behaved charmers turn into insufferable demons racing towards self-destruction.

Well, I think I know what an overtired Mac is like. If it doesn’t get some sleep every week or so, Time Machine’s backups and other scheduled background activities become irregular, or simply stop happening.

It’s a bug that some of us have suffered from since Sierra 10.12 was first released. I think it may have been around in El Capitan too, but no version of El Cap was ever stable enough on my iMacs for it to occur: they suffered kernel panics too often. It only seems to affect those of us who leave our Macs running for long periods, more than a week or so, although it can sometimes strike sooner than that. And – most significantly I believe – it comes on more quickly (perhaps only) if you do not allow your Mac to go into system sleep.

The underlying mechanism is a breakdown in DAS and CTS, the activity scheduling and dispatching systems which are responsible for running backups and over 70 other services in Sierra. Leaving your Mac running without system sleep proves too much for DAS in particular, and after a period of seven days or more, it fails to schedule and dispatch activities properly. I reported this to Apple in February, but so far there is no sign of the bug being fixed.

Until now, the normal solution, when the bug occurs and backups become irregular, has been to restart. That is acceptable for Macs being run for normal use, but not a feasible option for most server systems, for example.

The Time Machine Mechanic, T2M2, available free from Downloads, is the only app capable of detecting and diagnosing the problem (as well as many other issues with backups).

Following my analyses of Sierra’s unified log for sleep and wake events, it occurred to me that cycling a Mac through those seemed to regenerate the scored dispatch list used by DAS, thus might stave the bug off. Over the last few weeks, I have been experimenting with this, and am delighted to report that it seems successful.

longrunner

My recommendation therefore is that if you want to leave your Mac (Sierra 10.12.x, possibly earlier too) running continuously, and do not want it to enter system sleep on a daily basis, you should deliberately put it to sleep at least once a week. It does not have to be asleep for more than a few minutes, it would appear. If you don’t want to schedule this manually in the Energy Saver pane, you should also be able to use the pmset command
pmset sleepnow
in Terminal, or schedule a weekly sleep, perhaps.

When the bug has occurred, and backups have become irregular, you should also be able to use system sleep as a way to regenerate DAS, so that backups become regular again: try forcing system sleep for a few minutes, and after waking up, scheduled backups should return. I haven’t yet had a chance to try this out, as my Mac’s weekly sleeps have prevented the bug from occurring, so far.

If Apple provided us with some way of telling DAS and CTS to behave as they do when going to sleep and waking up, I suspect that could spare us having to use whole-system sleep.

If you have been troubled by this bug, please give this a try, and let us know here whether it also works for you. In fact, if you’ve got any good solutions for overtired children, I’m sure those might be of interest too 😄.