How do I retrieve files from Time Machine backups from another computer?

Really it's the same computer - I just did a fresh install of Snow Leopard. When I try to open the Documents directory from my old user account I get

The folder "Documents" can't be opened because you don't have permissions to see its contents.

I think the problem is that my user account ID changed when I installed Snow Leopard. It was 503; now it's 501:

ls -al /Volumes/ExternalDriveName/Backups.backupdb/ComputerName/2009-09-03-120049/ComputerName/Users/
drwxr-xr-x@ 43 503    staff  1462 Jul 20 15:14 gaius

echo `id -g` `id -u`
501:20

I tried both chown -R and chmod -R, but both give me

Operation not permitted

I also tried changing the permissions via Inspector. They're all greyed-out, even when I authenticate as an administrator.

Any help?


Solution 1:

You could also invoke "Enter Time Machine" as root. That requires Finder to be started as root first, so only for those who understand the risks. In Terminal, for both Leopard and Snow Leopard:

sudo /System/Library/CoreServices/Finder.app/Contents/MacOS/Finder

In Snow Leopard this does not (always?) open an initial Finder window. Do not click the Finder icon in the Dock (which might take you to your normal Finder), but use Command-Tab to go to Finder (which will be the new root-Finder). Here, hit Cmd-N for a new Finder window.

The new Finder looks like a normal Finder, but you'll notice root next to the home folder icon in Finder's sidebar. While the root-Finder is active, enter Time Machine (and once again validate that root is shown next to the home folder icon). This should allow you to browse, delete or restore what you need (but, for the original question: it won't solve your access issues permanently).

(As usual, holding down Option while clicking the Time Machine icon will change "Enter Time Machine" into "Browse Other Time Machine Disks" if you need to examine a disk that is not associated to your current machine. You might not need to be running as root to do that though!)

When done, eject the Time Machine volume if applicable. Next, hit Ctrl-C in Terminal to stop the root-Finder. The usual Finder will still be running, but in Snow Leopard the indicator in the Dock may have gone. Run killal Finder if that bothers you. (And if you forgot to eject the Time Machine volume while you were still root and the disk doesn't unmount properly at a later time, or if Time Machine won't mount it correctly when running its hourly backup, then you may simply log off as an easy fix.)

(If anyone knows how to do this without first running a root-Finder then please tell us! Running sudo "/Applications/Time Machine.app/Contents/MacOS/Time Machine" does not give the expected result, and I assume that the Time Machine galaxy window is in fact part of Finder. For the sake of search engines: "run time machine as root", "start time machine as root".)

Solution 2:

It appears that Apple sets an ACL that denies everyone (root included) from deleting or modifying ownership etc on the Backups.backupdb folder and its contents, so using sudo or other root access does not help to change permissions.

drwxr-xr-x@   4 501   staff    136 18 Jun  2008 backedupfolder
com.apple.metadata:_kTimeMachineNewestSnapshot     50 
com.apple.metadata:_kTimeMachineOldestSnapshot     50      0: group:everyone deny add_file,delete,add_subdirectory,delete_child,writeattr,writeextattr,chown

everyone deny add_file,delete,add_subdirectory,delete_child,writeattr,writeextattr,chown

You can gain access to folders that are inaccessible by the current user by setting Ignore Ownership on the Time Machine volume. Unfortunately Apple have removed this from the Get Info window for volumes that are Time Machine volumes (or have been used as such in the past).

You will need to instead set the Ignore Ownership for a volume from the terminal instead.

vsdbutil -d '/Volumes/TimeMachineVolume'

You can reverse this using

vsdbutil -a '/Volumes/TimeMachineVolume'

As soon as TimeMachine runs again it will also re-enable ownership on the volume.

Solution 3:

on the command line you should be able to type

sudo su

and be authenticated as root. If the root user is unable to access the files, then you're most likely running into a data corruption problem.


Fixing Disk Corruption:
  • DiskWarrior - great for repairing HFS+ (mac formatted) drives, but not free
  • OnyX - Has some nice drive repair, free.

Solution 4:

I had a similar problem where I copied the Time Machine backup files back to my hard drive after a clean install of Snow Leopard. iTunes couldn't read the music directory and I had to type my password to trash the files. My fix was to remove the extended attributes for all the files. I don't have the script I used on me, but a Google search came up with this:

http://zzamboni.org/brt/2008/05/07/removing-all-extended-attributes-from-a-directory-tree/

Solution 5:

One successful method:

  1. I used Migration Assistant to migrate the account from the Time Machine backup onto the new Snow Leopard installation. If Snow Leopard sees that you're trying to migrate in an account whose name already exists, it will prompt you to create a new name. I did this.
  2. I logged in as the migrated account.
  3. I dropped everything I needed into my real account's Drop Box.