With APFS-based TimeMachine backups, the -a
option apparently does not work and just shows a misleading error. I have a TimeMachine backup on an external drive as well as on a NAS (i.e. network drive) within a .sparsebundle
image, the latter being suddenly broken (i.e. still same Mac and same backup locations, but the gist of below should still apply to this question). The following assumes knowledge of the command line and what sudo
is.
Before going ahead, I made sure the external drive was unmounted and removed from the Mac to not confuse myself and "protect" the functioning backup from inadvertent actions. I rebooted the Mac and performed all steps from an account with administrative privileges and enabled for sudo
. Make sure you know the password of your encrypted TimeMachine backup; you may be able to recover it from the macOS keychain application, though.
In my case, the NAS backup broke (could no longer mount the sparse bundle image), which I fixed by switching TimeMachine backups to "manual only" and making sure to stop any ongoing backup processes, then removing only the NAS-backup from the macOS preferences and rolling back the NAS drive/folder containing the sparse bundle file to a (btrfs) snapshot that predated the last successful TimeMachine backup. I knew the system could mount the bundle image for this last backup, hence I did not try a later snapshot, plus the chosen snapshot was luckily just created the night before.
A reboot at this point may not be necessary, but I like a clean slate and this may also help remove any stray mount points. I then re-added the NAS as backup drive in macOS preferences, which detected the existing backup and asked me whether to continue using the "old" backup. I confirmed, but when I browsed the backups through the TimeMachine UI, the old versions did not show up even after waiting quite some time.
I've then re-associated my disk this way:
- Manually mount the network drive containing the TimeMachine-backup via Finder (but do not mount the sparse bundle image itself!).
- In the Terminal, executed
sudo tmutil inheritbackup /Volumes/<shared-network-drive-name>/<my-mac-name>.sparsebundle
. This reported to me that a backup of the same name was already associated with my Mac, which confirmed to me that the UI prompt of re-using the "old" backup did in fact work.
- Via Finder, mounted the sparse bundle image from the network drive. This may take a while, and prompted me for the backup password. Eventually, Finder opened with the list of available snapshots that I could browse (when browser in Finder, those backups are mounted at
/Volumes/.timemachine/<ID>/<date-and-time>.backup
).
- Internally, the sparse bundle image was mounted at
/Volumes/Backups of <my-mac-name> 1/
, but the name may be different for you. Note down the path, which I'll call /Volumes/<backup-image>/
below. I checked the contents of this folder via ls /Volumes/<backup-image>/
. Interestingly, it did not show all the backups I could browse from Finder (see previous step). Luckily, this wasn't an issue for me in the end, but I don't understand this point. More importantly, I could confirm the most recent backup date-and-time (take note of that for the next step) was matching with what I could see in Finder.
- Using the most recent , executed
sudo tmutil associatedisk "/Volumes/<name-of-primary-mac-disk>" "/Volumes/<backup-image>/<date-and-time>.previous/<name-of-primary-mac-disk> - Data“
. Note that my Mac's primary disk is named "Macintosh HD" and the one on the backup is localized, i.e. it showed "Macintosh HD - Daten" for me, both of which may be entirely different for you. This command did not show any error messages and seemed to do the trick, at least after some time, as confirmed in the following steps. You may need to repeat this for further backups, see note below.
- The network connection to my NAS in combination with TimeMachine seems quite flaky, so I had to reboot once or twice again. When I then opened the TimeMachine UI, all the old backups appeared again for browsing any local folder (after some 5-15s to account for network and NAS disk reading latency). I could not select all of the available backup versions as the folder I was browsing was not contained in every backup – when I moved to my Mac's main disk within the TimeMachine UI, however, I could select all backup versions, which confirmed to me that everything was working.
- Now it's time to re-set the preferred TimeMachine backup interval and allow it to perform a backup, which will take quite some time as the system has to re-scan and compare all files. Afterwards, re-check that you can browse all previous backups from within TimeMachine UI.
In some cases, you may need to allow TimeMachine to start a backup in step 6 (does not need to complete) before it recognizes the older versions available on the TimeMachine backup.
If just the most recent backup that you actively associated is available, you may need to repeat the step 5 for all the other disks. Below, untested(!) script may help speed up the process:
PRIMARY_MAC_DISK_LOCAL="<name-of-primary-mac-disk>"
PRIMARY_MAC_DISK_BACKUP="<name-of-primary-mac-disk> - Data"
BACKUP_IMAGE="/Volumes/<backup-image>"
for ver in $(ls $BACKUP_IMAGE)
do
if test -d "$BACKUP_IMAGE/$ver"
then
echo sudo tmutil associatedisk "/Volumes/$PRIMARY_MAC_DISK_LOCAL" "$BACKUP_IMAGE/$ver/$PRIMARY_MAC_DISK_BACKUP"
fi
done
Note that in this case, my mis-match issue mentioned in step 4 may become a problem as those backups will not be associated.
References: