6

I've been using an HFS+ drive for Time Machine, but I recently formatted a drive in APFS as my Time Machine backup drive on macOS Monterey. Now I find the implementation with APFS very confusing. If I list things on the root directory of the drive with ls, the results are as follows:

.fseventsd
.Spotlight-V100
2022-12-03-020353.previous
backup_manifest.plist

And upon further inspection, 2022-12-03-020353.previous only contains the latest version of files, older backups are not visible. On an HFS+ TM backup drive, there should be a Backups.backupdb that contains all the backups with timestamps, which to my understanding is no longer the case for APFS since Big Sur. Now if I do tmutil listbackups, I still get a list of backup timestamps instantly, which looks like the following, though I don't know what to do with them:

……
2022-12-02-151624.backup
2022-12-02-171818.backup
2022-12-03-000232.backup
2022-12-03-020353.backup

From what I found online, the older backups are stored as APFS snapshots, the question is though, how do I restore specific files from them? I mean, without the Time Machine GUI, but in the command line with tmutil? On HFS+ drives I can simply do tmutil restore /Volumes/TM/Backups.backupdb/<timestamp>/Macintosh HD/<src> <dst>, how do I do the same thing with an APFS drive? Do I need to mount a specific snapshot first before restoring? How to do that in the command line with timestamps gathered by tmutil listbackups? Because waiting for snapshots for the backup hard drive to appear in Disk Utility.app takes forever.

Apologies if this has been asked before, but search engines haven't been kind to me, all I could find about APFS TM backups were about local snapshots and deleting a backup by timestamp.

4
  • Welcome to Ask Different! :) I hope you come to find this site has a lot to offer! In case you haven't already, it's worth taking the time to read the tour. All the best!
    – Monomeeth
    Commented Dec 3, 2022 at 9:57
  • I do restores using Finder which knows about the snapshots on APFS TM destination volumes. Just choose the date and drill down to what you want to restore. With APFS there is no Backups.backupdb folder, the snapshots are visible to Finder. The snapshots are NOT visible to command line utilities like ls.
    – Gilby
    Commented Dec 3, 2022 at 10:34
  • 1
    If you found an answer, post is an answer to this question, not as an edit/update to the original question.
    – Allan
    Commented Dec 30, 2022 at 9:04
  • Thanks for your suggestion, I'm pretty new to stackexchange. Commented Jan 13, 2023 at 22:03

1 Answer 1

2

I figured it out myself, here's the answer, in the form of a Bash script, use at your own discretion. Basically you have to mount a backup snapshot with mount_apfs by its name, which can be obtained through diskutil info, then you can access the files normally with whatever tool you like.

Also, I learned that the Time Machine GUI essentially does the same thing, it just mounts all of the snapshots under /Volumes/.timemachine/<backup volume UUID>, but you have to enter the TM GUI once after each re-mount, otherwise it only mounts the oldest snapshot, but the TM GUI isn't controllable from a script (maybe possible with AppleScript? idk). Also, it does mounts all the snapshots when OS restarts.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .