Removing backups from Apple’s Time Machine

Apple’s Time Capsule is a neat device that provides both wireless access, router functions, and a hard drive for doing automated backups from one or more Macs in the same network.

It’s very easy to use and “just works.” If it runs short on disk space it starts to automatically trim the oldest backups automatically. No intervention needed.

But ease of use often means functionality can suffer, and in one area that this is true with Time Capsule and Time Machine is when it comes time to add another machine to it and there’s not enough space on it to do the first backup.

Which is what happened to me. I purchased a new Mac and wanted to add it to my Time Capsule without reformatting it and removing all my old backups from the two other computers on it. Pruning it manually is a bit of a bear. Hence this blog post.

First step is how to manually prune selected backups. To do this, run Time Machine and in the Finder window should be a disk mounted named “Backup of” followed by your computer name. Go to that, open the Backupdb.backup folder, then the folder for your computer. Inside should be a folder for each backup by date, similar to the pic below. Click the cog wheel and select “Remove all backups of” and the generations you want to remove. If you want to remove all backups, do it at the folder above it named after your computer.

You should be promoted to confirm your password (since this is an obviously dangerous thing to do).

Now this is where it tripped me up. There was no visual confirmation anything was happening. I continued with doing it to a few more. Still no confirmation. I quit Time Machine and then saw a deleting window — which stayed there for hours and hours.

But eventually it finished. Yay!

But guess what, the disk showed no additional free space. Arrggh….

The answer turns out you need to compress the “sparse bundle” to free up the space. This is where it gets hairy. To do this requires a command typed into the terminal window.

To help you get the right filename, first do the following. Go into a Finder window (while NOT in Time Machine) and find the disk for your Time Capsule. Mount it, and dive into the folder where it has a large file for each machine you back up ending with .sparsebundle in the filename.

The trick is to enter this filename into the terminal window as an argument to the hdiutil command. The best way to do this is to first copy the file name into the clipboard as shown below. DO NOT SELECT COMPRESS IN THE COG MENU. That is not the same thing as what we are trying to do.

Now go into the Applications folder, find the Utilities folder, then the Terminal application. Run it. At the prompt carefully type in (but don’t hit return yet):

sudo hdiutil compact

Have at least one space after the word compact, then press CMD-V to paste in the sparsebundle filename. This is what mine looked like:

Exactly what I was looking for, I had absolutely the same issue where I wanted to add a second Mac to my Time Capsule. I got as far as deleting the backups but could not figure out why my disk space was staying the same.

I actually found that I can use the terminal window the manually “sudo rm -fR *”d the files. I think it is much faster than using the Time Machine/Finder (presumably because it bypasses the trash and just ditches the files in one fell swoop.) However, your way is probably easier.

Still, after it was all done I was absolutely shocked to find that the disk space was still not given back to me! Your “sudo hdituil” did the trick perfectly, however -Thanks again!

I followed your steps but I keep getting this error “hdiutil: compact failed – internal error”. Any thoughts on what is going wrong? I’m running 10.5.8 on a iMac and 10.6x on two laptops, with a 1tb duel banded Time capsule. Do I need to make sure that Terminal is the only thing running?

Please paste in the command you used that didn’t work. But don’t get your hopes up because I’m not an expert on this utility at all. Alternatively I’d suggest just Googling that error. I *think* you might also be able to mount the sparsebundle within disk utility program and verify it using that. But right now I’m not anywhere I can test that myself.

If you have any spaces in your file name (most likely) you have to either escape them (put a in front of each one) or surround the entire name in a single quote. Or just copy and paste the file name as I did above and it should be specified correctly.

Any thoughts on how you delete the backups of a machine you no longer have? I can’t “run Time Machine and in the Finder window should be a disk mounted named ‘Backup of’ followed by your computer name” for a machine that no longer exists, yet I still want to clean out its backups.

thanks for posting this…has saved me a ton of headaches
one thing you could add to make it even easier is that you can simply type

sudo hdiutil compact

then go to your time capsule file (xxx.sparsebundle) and simply drag it into the Terminal window…this will copy the full path and file name in your Terminal..
less likely to forget a space or an escape character.

Just wanted to drop a note regarding another comment –
“sudo rm -fR *”
This is a really quick way to delete everything on your hard drive, it really does work in seconds. So, if you do choose to use it, understand that it’s very risky and if you mess up one of the commands before it, it will wipe your computer.