Creating APFS snapshots for non-boot volumes in macOS with Carbon Copy Cloner

Like other modern filesystems, APFS supports volume snapshots with robust copy-on-write. After you create a snapshot, any data written to the volume is in addition to the contents of the snapshot. So a snapshot only “uses” as much disk space as the delta between the snapshotted state and the current state. Rolling back to the snapshotted state is quick, and doesn’t require any partitions or duplicating of data.

Unlike other modern filesystems, APFS doesn’t provide admin-friendly tools for creating snapshots. The closest we have is tmutil, which only works on the current boot drive.

Fortunately, Carbon Copy Cloner fully implements creating, managing, and restoring APFS snapshots on any volume connected to the system.

At work, I’m currently testing MDM Automated Device Enrollment for our fleet of Macs. Testing ADE repeatedly meant getting macOS to a clean state (pre-Setup Assistant) every time I wanted to test config changes on my test machine. Re-installing macOS took about an hour, which was not ideal. If I could create a snapshot of a clean installation of macOS, then revert to that snapshot, progress would be much faster.

As it turns out,tmutil can’t be run from Recovery (even if you load the binary into a Recovery terminal). And of course it can’t be run in macOS until after Setup Assistant. So officially-blessed solutions notforthcoming, I put my test machine into Target Disk Mode, connected it to my work computer via Thunderbolt, and then in Carbon Copy Cloner, selected the data volume, and triggered and then canceled a clone task to an external drive. This had the intended effect of creating a snapshot of the data volume on my test machine. When I was ready to revert to the snapshot, I just had to put the test machine into Target Disk Mode again, connect it to my work computer, and in CCC, select the snapshot. Reverting took about 10 seconds each of the several times I had to re-test my ADE config, saving me several hours in total.

The fact that Apple hasn’t provided a way for admins to create volume snapshots on just any APFS drive — though does provide a way to list or delete them via diskutil — betrays an opinion that volume snapshots are only useful for Apple engineers building tools like the OS updater and Time Machine. Actually, I think admins would use this feature if it was available to them, as it has been in Windows since 2003, and Linux since 2005.