MacOS – How to mount a Time Machine sparsebundle so I can modify it

macosmountsparsebundletime-capsuletime-machine

TL;DR: I have a Time Machine backup that I want to modify before running Migration Assistant, but when I try to delete a directory from it either with rm or unlink I get "operation not permitted". How can I mount it so I can make a change?

The reason I'm at this point:
Upgrading my iMac from Mountain Lion to Mavericks went so badly that I eventually booted from a USB key, reformatted my hard drive, and re-installed.

I have a Time Machine backup on a 3TB AirPort Time Capsule, but restoration was painfully slow (even over a wired network) so I gave up that as well.

I copied the sparsebundle for the machine I'm trying to restore to an external FW800 disk and plugged it into my iMac. Started Migration Assistant, then ssh'd in and mounted the sparsebundle. At that point I was able to select it in Migration Assistant, select the account I want to restore, and begin the process. This took another ~20 hours before showing me the progress bar for ~30 minutes of copying.

During the 20 hours I was able to run some dtraces over the ssh connection and ascertain that most of the time was spent picking through the files in /Library/Ruby/Gems/1.8/gems. I want to run Migration Assistant again to restore my applications – I figure it will be quicker than re-installing / re-licensing everything. In order to hopefully eliminate most of the 20 hour wait, I want to remove the gems directory before running MA.

I (think I) know how hard linked directories work in TM backups. /Library has a different inode in the "Latest" backup, compared to the previous timestamp. /Library/Ruby has the same inode in both. Therefore I'd be content with just unlinking /Library/Ruby in Latest.

bash-3.2# pwd
/Volumes/Time Machine Backups/Backups.backupdb/numberwang/2013-10-23-192429/Macintosh HD/Library
bash-3.2# ~/hardlink -u Ruby
hardlink: Operation not permitted
bash-3.2# mv Ruby old.Ruby
mv: rename Ruby to old.Ruby: Operation not permitted

Best Answer

You can delete all backups of specific folders from the Time Machine interface.

  • Enter Time Machine (from the Time Machine menubar interface or from the Dock)
  • Navigate to the /Library/Ruby/Gems/1.8/gems folder
  • While the gems folder is selected, right click and choose Delete All Backups of <items(s)>
  • Confirm that you wish to delete it and enter the Administrator credentials

If you have changed your machine's name after the reinstall, then Time Machine won't show your older backups. You can either rename your machine to the name it had before or press Option while clicking on the Time Machine menubar item and select Browse Other Backup Disks... to go through your backups.

See Should I delete old backups? If so, How? for more information and other ways to work with the AirPort Time Capsule.