Ever since upgrading to macOS Sierra, I have noticed days when Time Machine backups occur very irregularly. I first reported this here, and it hasn’t really gone away. To be more precise, it goes away, and then returns.
At first, I thought that Time Machine had become smarter, and varied the frequency of backups according to the need, somehow. That doesn’t make a lot of sense, as backups are scheduled using launchd
, the macOS replacement for Unix cron
, which doesn’t allow such sophistication. But maybe there was something else in macOS which was monitoring disk write activity and overriding the standard hourly regime?
The other day, I sensed that backups had become irregular again, and used my Consolation tool to check logs. They showed that backups had been started at:
0818,
0858,
1223,
an attempt at 1231 was aborted because it was too soon since the last,
1559,
aborted attempt at 1617,
1916,
aborted attempt at 1931,
2301,
aborted attempt at 2313,
0652.
At no time over that period did my iMac17,1 sleep, as I have set it to only sleep the display.
The only unusual feature is that, at that time, my iMac had been running continously, without sleeping, for nearly two weeks.
Although I like to leave my iMac running at all times, every week or two I usually restart it. When you’re developing your own apps and doing other brutal things to macOS, it gives the system a chance to start afresh. So I thought it might be good to restart. Since I have done so, backups have returned to their hourly schedule, just like they always had done. And I haven’t seen any that have been aborted because they were going to start too soon after the last backup.
This is not ‘smart’ backup, but simply broken scheduling.
I think that this is evidence that, as far as backups are concerned, at least, scheduling fails when macOS Sierra has been running continuously for more than about 10 days. After that time, launchd
‘s scheduler seems to behave erratically, and instead of running backupd-helper
, the service which initiates Time Machine’s backups, at regular hourly intervals, it literally loses track of time, and schedules almost at random.
If this is a launchd
bug, such as a memory leak, it is unlikely to be confined to backupd-helper
, but probably affects all scheduled services.
So my advice is not to leave a Mac running macOS Sierra 10.12.x for more than ten days or so without sleep or a restart. I don’t know if system sleep would correct this, but restarting seems to.
Explanation of backup scheduling
Like all macOS scheduled tasks, Time Machine uses a property list (.plist) file to configure its behaviour. This is located at /System/Library/LaunchDaemons/com.apple.backupd.plist for the basic backupd
service, and at /System/Library/LaunchDaemons/com.apple.backupd-helper.plist for the timed backups run via backupd-helper
.
launchd
is the macOS ‘master’ process which launches all processes, services, and apps once the kernel and launchd
are running. Every hour, when your Mac is awake, launchd
should launch backupd-helper
, which then initiates the Time Machine backup.
If you wanted to alter the frequency of backups, you could in theory edit com.apple.backupd-helper.plist to set that. In practice, that file is protected by SIP. So utilities which allow you to alter the frequency of backups now have to turn Time Machine off, then create their own property list in an accessible folder such as /Library/LaunchDaemons to schedule backups to your requirements.
When launchd
was first introduced, it had a succession of major bugs, and sometimes barely worked. However, as far as I know, there have been no significant bugs in it for several major releases of OS X. I believe that this probable bug is new in Sierra.