Skip to content

Instantly share code, notes, and snippets.

@martian111
Last active July 29, 2024 02:48
Show Gist options
  • Save martian111/e0d9885004eb56fd6abf3d1ba7671737 to your computer and use it in GitHub Desktop.
Save martian111/e0d9885004eb56fd6abf3d1ba7671737 to your computer and use it in GitHub Desktop.

My Time Machine Notes

Migration from External HDD to Samba

  1. Create Samba share using a combination of the following references:

    1. https://kirb.me/2018/03/24/using-samba-as-a-time-machine-network-server.html
    2. https://www.reddit.com/r/homelab/comments/83vkaz/howto_make_time_machine_backups_on_a_samba/
  2. Reviewed the following references for ideas on how to migrate Time Machine backups from external HDD to Time Capsule:

    1. https://jason-townsend.blogspot.com/2008/08/how-to-transfer-local-time-machine.html
    2. Note the reference did not provide a step-by-step guide for me because of several differences in my setup. First, my external HDD was formatted in exFAT (due to its size) and thus, did not have Time Machine backups directly on it. Instead, an encrypted sparse bundle with HFS+J filesystem was created on the external HDD and mounted manually each time I wanted to do a backup.
    3. With Time Machine backing up to a network drive, I could have just moved the sparse bundle from my external drive to the shared volume, and mount it manually as usual to do Time Machine backups. However, major downside to this is that I miss out on the benefit of automatic backups.
    4. If I started fresh (without migrating my old backups), then Time Machine would, on first backup, create a new sparse bundle on the SMB network share and name it MachineName.sparsebundle. This new sparse bundle contains a HFSX filesystem with a capacity that matches the capacity of the network share, unless global quotas are set up via the .com.apple.TimeMachine.quota.plist file.
  3. To manually migrate the Time Machine backups to a Samba share:

    1. Create a blank sparse bundle image at the root of the Samba share used by Time Machine. Name it MACHINE_NAME.sparsebundle in the "Save As" field (this file name is what Time Machine uses when creating a new, blank image).
    2. Set the size of the new sparse bundle as appropriate (max size of backups, should be greater than the size of the HDD/SSD of the system being backed up).
    3. Time Machine uses "Mac OS Extended (Case-sensitive, Journaled)" by default when creating a new sparse bundle automatically. Select "Mac OS Extended (Journaled)" if the source backup files are contained in a non-case-sensitive system. Otherwise, when copying the Backups.backupdb directory later on will fail with The volume has the wrong case sensitivity for a backup.
    4. Name the volume "Time Machine Backups" (in the "Name" field, not "Save As" field).
    5. Mount the newly created sparse bundle.
    6. At this point, the "Time Machine Backups" should be mounted without "enableOwnership". Enable it by:
      1. Run diskutil list on the Terminal to find the "IDENTIFIER" for the "Time Machine Backups" volume.
      2. With the found identifier, run sudo diskutil enableOwnership IDENTIFIER
      3. Example:
        /dev/disk5 (disk image):
           #:                       TYPE NAME                    SIZE       IDENTIFIER
           0:      GUID_partition_scheme                        +1.0 TB     disk5
           1:                        EFI EFI                     209.7 MB   disk5s1
           2:                  Apple_HFS Time Machine Backups    999.7 GB   disk5s2
        
        The command would be sudo diskutil enableOwnership disk5s2
    7. Unmount/eject "Time Machine Backups" and remount it. Verify in "Disk Utility" that the "Time Machine Backups" volume is mounted with "Owners" set to "Enabled".
    8. Copy Backups.backupdb from source volume to the newly created "Time Machine Backups" volume. It should prompt for user password as this requires root.
    9. Unmount volume when copy is completed.
    10. Some Time Machine metadata files are needed within the .sparsebundle directory for Time Machine to recognize it properly. Without it, Time Machine will create a blank, new sparse bundle with " 1" appended to the file name, ignoring the sparse bundle created here. The needed metadata files are:
      1. com.apple.TimeMachine.MachineID.plist and com.apple.TimeMachine.MachineID.bckup (the bckup file is just a copy/backup of plist):
        <?xml version="1.0" encoding="UTF-8"?>
        <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
        <plist version="1.0">
        <dict>
        	<key>VerificationDate</key>
        	<date>2019-09-04T07:12:34Z</date>
        	<key>VerificationExtendedSkip</key>
        	<false/>
        	<key>VerificationState</key>
        	<integer>1</integer>
        	<key>com.apple.backupd.HostUUID</key>
        	<string>MAC_HARDWARE_UUID_PER_SYSTEM_INFORMATION</string>
        	<key>com.apple.backupd.ModelID</key>
        	<string>MAC_MODEL_IDENTIFIER_PER_SYSTEM_INFORMATION</string>
        </dict>
        </plist>            
        
        All information missing above can be found via the "System Information" application included with macOS, within the default/first information pane titled "Hardware Overview".
      2. com.apple.TimeMachine.SnapshotHistory.plist - Can use the blank template below as-is. Time Machine will popuplate this file when it is switched over to use this sparse image.
        <?xml version="1.0" encoding="UTF-8"?>
        <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
        <plist version="1.0">
        <dict>
            <key>Snapshots</key>
            <array/>
        </dict>
        </plist>
        
    11. Open Time Machine Preferences and switch over the Samba share (via "Select Disk" option).
      1. Note Time Machine will ask you to either "Replace" the backup disk or allows you to "Use Both".
      2. Upon first backup, it may prompt you with a warning that the backup disk may have been tampered with. This can be ignored if it is certain there was no other tampering with the backup data except for the steps done above.
      3. If all worked above, then it should find the sparse bundle created above, mount it, populate data in com.apple.TimeMachine.SnapshotHistory.plist and continue backup where it last left off on the old backup drive.

Debugging

Other Useful References (Potentially for Future)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment