Time Machine to APFS: Maintenance and repair

Time Machine was originally designed to be low-maintenance, integrated with Mac OS X, and easy to use. As we’ve done more complex things with our Macs, and storage capacities have risen, it had reached the point where, for many users, it simply wasn’t working. In this article I look at what maintenance Time Machine backing up to APFS (TMA) should need, and what’s available to repair it.

Given sufficient free storage space, TMA shouldn’t need any additional routine maintenance. Each backup consists of two snapshots: a short-life whole-volume snapshot is saved to each volume being backed up, and those are removed (‘thinned’) once they’re 24 hours old. Occasionally, old snapshots may become orphaned in error, and they can be maintained using the tmutil command. Because snapshots themselves aren’t exposed in the Finder or Disk Utility, third-party utilities such as Carbon Copy Cloner can be used in preference.

Snapshots forming backups on the backup store can be deleted in the Finder, or using tmutil, but the user can’t delete or modify backups in the Time Machine app itself. Currently, there’s no way to modify the contents of a snapshot, which means that users can’t delete individual backed-up items at all. If a backup inadvertently captures a very large file which you want to remove, the only way to do that is to remove that whole backup.

backupstructurediffs

The fundamental differences in backup store structure are shown in this diagram. On the left, an HFS+ backup store puts all the folders, files and hard links into the one file system of a single HFS+ volume. That file system has to be kept live, and each time that a new backup is added to it, the file system changes and grows in size. On the right, an APFS backup store consists of one APFS volume containing the last backup and Spotlight indexes. Each backup is contained within the file system of its own snapshot. Once those have been made, their separate file systems are read-only, and can be unmounted. Adding a new backup only changes the file system of the backup volume, and doesn’t affect any previous backup snapshots.

Big Sur does perform one routine maintenance task on the backup store which can appear worrying. Periodically, backup snapshots are indexed by Spotlight for the volume’s Spotlight-V100 indexes. This may require background mounting and unmounting of those snapshots, and often results in the spinning Time Machine icon being displayed against that volume in the Finder. This occurs for long periods, and more obviously, soon after a new backup store has been put into use, but later becomes briefer and less likely to be noticed. If there’s any concern over what’s happening, these are marked by entries in the log (which can readily be browsed using Mints).

Backup store maintenance should be minimal. As with any APFS volume, Disk Utility and its command tool equivalent diskutil are used to check and repair backup snapshots. Each snapshot is automatically checked when First Aid is used on the backup store volume. The recommended command in Terminal is
diskutil verifyVolume disk7s2
when you want to check the volume at disk7s2. This typically unmounts the volume, performs
fsck_apfs -n -x /dev/rdisk7s2
on it, then remounts it on completion. Even apparently empty snapshots take some seconds to check, so with more than a few backups, this process can take an hour or more. There’s currently no option to check individual snapshots.

Once created, backup snapshots can’t be modified by the user. Their file systems are small and of fixed size, therefore they should be as completely reliable and robust as is possible on their disk. However, as backup snapshots can’t be copied or backed up themselves, users who want improved robustness can only use mirrored storage, and the only way to keep a copy of the backup disk off-site would be physically removing one disk from a mirror set.

Apple’s troubleshooting guide is brief, and doesn’t even refer to using Disk Utility to check and repair TMA backup volumes. However, it does link to the warning that “in rare cases, Time Machine can’t back up software from companies other than Apple due to a setting made by that software. For more information, contact the manufacturer of the software.” No further details are given.

A linked article claims to explain how to verify the backup disk using the Verify Backups command accessible by holding the Option key when opening the Time Machine menu in the menu bar. However, when TMA is the active form of Time Machine, that command isn’t enabled. No alternative is suggested.

It’s currently unclear whether the tmutil command tool is able to verify checksums on TMA backups. There’s no indication in the man page or usage information that this command doesn’t work, and using it on a mounted TMA backup snapshot doesn’t return an error either. A command such as
tmutil verifychecksums /Volumes/.timemachine/CBD008EA-E190-4C11-82AE-7C0E10A9811A/2021-03-23-115332.backup
appears to work, but as it only returns errors it’s unclear whether it’s checking any checksums at all.

Although APFS metadata, including that saved in snapshots, uses checksums to verify integrity of the file system, macOS offers no other way of verifying the integrity of files in snapshots. One solution is to tag files prior to backup using Dintch, Fintch or cintch; those store hashes to extended attributes which are preserved when backed up, and can be checked but not changed in mounted snapshots.

The single most useful utility for working with TMA backup snapshots is BackupLoupe.

tmtools

For anyone working with, or wanting to access, TMA backups, this is an essential app. Although it sets out to provide a complete alternative interface to backups, it doesn’t have to be used as a replacement. It has many powerful features, including the ability to calculate differences between backups, but its most general benefit is to ensure that backup snapshots are conveniently mounted in the path
/Volumes/.timemachine/[UUID]
This ensures that they remain accessible to third party apps and through the command line without having to be individually mounted. However, BackupLoupe doesn’t provide any additional tools for backup maintenance or repair, other than another means of deleting individual backups.