Time Machine to APFS: How processes have changed

Now that I’ve worked through the steps involved in an automatic Time Machine backup to APFS local storage (TMA), this article draws that out into a chart, and compares that against the processes used when backing up to HFS+ in Catalina (TMH). This also demonstrates why Big Sur’s Time Machine is version 1.3, and not version 2.0.

tmbackupapfsbigsur

The first snapshot phase in TMA involves connecting to the mountpoint and machine store in the backup storage, deleting expired snapshots from the volumes being backed up, making the stable snapshot on each volume being backed up, and mounting that and the previous or reference snapshot.

Next, in the event collection phase, TMA has to work out what on each volume needs to be backed up. It normally does this in TMA by collecting events from FSEvents, as at present it doesn’t back up the System volume, or any of the hidden volumes in the boot set. The event cache is then saved as the .eventdb file.

In the sizing phase, using the event cache, TMA estimates the disk space required to perform the backup. If there’s insufficient space available in the backup store, that should generate an error informing the user of the problem.

If there is sufficient free space, TMA then proceeds to the copying phase, when it copies items from the source to the .inprogress folder on the backup store which provides the data for the backup. In larger backups, this is the most time-consuming step, and is normally accompanied by periodic progress reports in the log.

Once copying is complete, the backup is matched against that expected by comparing the stable and reference snapshots. If there’s any discrepancy here, this should be recorded in the log. Snapshots are then unmounted and rotated ready for the next backup, and the more recent of the two is saved to the backup volume, where it’s used to form the snapshot which is the backup proper.

The final backup maintenance phase peforms housekeeping on backups in the backup storage, deleting them on the basis of age or, where necessary, to free up space for future backups. Once that is done, the backup is declared completed.

TMbackupAPFScat

This is a similar process to TMH in Catalina. TMA doesn’t back up to a sparsebundle, but to a structured APFS volume, and the backup is created quite differently, but otherwise the sequence and its steps are almost identical.

There are important differences, though, in the mechanisms underlying the backups themselves. TMH relies on hard links throughout its backups, whereas TMA constructs a snapshot complete with the data which is required. It isn’t clear yet whether the file system metadata in the snapshot contains that for the whole volume being backed up, or just constituent folders which are included in the backup, although in practice this is of little importance, as only the data required to be backed up are present.

Hard links used in TMH can only point to complete files, which doesn’t allow scope for individual storage blocks to be backed up, only entire files if they’ve changed since the previous backup. In TMA, because the snapshot handles storage blocks as well as files, there is considerable economy gained in only copying changed storage blocks. This allows TMA to make backups faster and smaller.

Using snapshots to store backups brings great rewards too. In TMH, the backup store is a single HFS+ volume which, over time, accumulates millions of files, directories, and hard links to both files and directories. This is inevitably prone to failure, and checking and repairing such a huge file system isn’t fast or simple. In TMA, each backup is single file system, which is much smaller and fixed in size once backing up to it is completed. These are checked and repaired individually, although working sequentially through a long series of such snapshots is time-consuming.

TMA backups are therefore inherently more robust and easier to maintain. Their only current disadvantage is that it’s not possible to delete items inside them, although complete backups can be deleted.

I will look in more detail at the structure and function of TMA backups in another article.