Mac – How to restore external hard drive from Time Machine backup the right way

backupencryptionexternal-diskrestoretime-machine

My Time Machine backup (6 TB USB-HDD) contains the data from my Mac's internal hard drive (2 TB) and from an external hard drive (USB 4 TB, Mac OS Extended, FileVault Encrypted) that I always keep attached.

Somehow my external 4 TB HD got corrupted and I need to reformat it. I want it Mac OS Extended, Encrypted, just as it was.

What is the right way to restore all the files from my Time Machine Backup so that Time Machine sees the hard drive as it was?

I had a similar problem before. Restoring the root folder of the HD with Time Machine was no problem, but Time Machine recognized the new formatted hard drive as a new one, resulting in a unnecessary new full backup of the HD, filling up my backup volume.

Best Answer

I found an answer over at superuser.com: https://superuser.com/a/1148703 But it seems there were some changes in MacOS so it did not work. But with this as a starting point I found a solution:

  1. Format the new drive (Or in my case the corrupted drive) with Disk Utility. Give it the same name as the old one. In my example "Daten"
  2. Go to the System Preferences - Time Machine and uncheck "Back Up Automatically"
  3. Go to the System Preferences - Security & Privacy. Unlock to make changes. Click on "Full Disk Access" and add Terminal.app from the Applications/Utilities Folder.
  4. Open Terminal.
  5. Put in sudo tmutil associatedisk -a. Then first drag your new Volume to the Terminal and after that drag the folder link Latest to the Terminal. You will find this folder link on your Time Machine Volume -> Backups.backupsdb -> Your Computer Name.
    The result should look like this: sudo tmutil associatedisk -a /Volumes/Daten /Volumes/YourBackupVolume/Backups.backupdb/Your\ Computer\ Name/Latest At the end of the line you need to add /Daten or whatever your failed HD was named.
  6. If the final result looks like this: sudo tmutil associatedisk -a /Volumes/Daten /Volumes/YourBackupVolume/Backups.backupdb/Your\ Computer\ Name/Latest/Daten press Enter, enter your password and press Enter again.
  7. Open the new volume in Finder. Start Time Machine. Restore all the files.
  8. Undo step 3.
  9. Undo step 2.

After that, Time Machine will see your new volume as the old one and will only backup the new files.

The reason why this is necessary is that Time Machine recognises the volumes not by their name but by their UUID, which is a long unique number that changes with every formatting. The associatedisk command tells Time Machine the new UUID of the volume.