Reclaiming Free Space from a Time Machine Backup

 | October 18, 2009 11:24 pm

Time Machine As much as I love Apple’s Time Machine, it’s a hard drive pig.  If not carefully watched, the little porker will use every spare byte of free space it can.  What is particularly obnoxious, however, is that you might not realize you have a problem until it is too late and you’re backup drive is filled to capacity.

Take my situation as an example.  I have a single MacBook Pro notebook with a 250 GB hard drive.  Most of my files are text based and on the smallish side.  In comparison, my networked backup  is a hefty 1.5 terabytes.  The combination of small hard drive and large backup drive had  me thoroughly convinced that I wouldn’t have to worry about free up space for years.

I was wrong.

Because of the size of the backup drive, I like to keep other files on it – mostly music and video files – so that I have a duplicate copy.  But earlier this week, I got a nasty surprise while trying to add an album I had just downloaded from Amazon Mp3.  The Mac informed me the backup drive was full.

As you might guess, I found this to be very confusing.  How could the drive be full?  Sure … I had three or four hundred gigabytes of music and video files on it, but there was no way that the Time Machine backup could be over a terabyte in size … Could it?

This situation didn’t smell right, so I decided to investigate.  I mounted the backup drive and tracked down the Time Machine sparsebundle and confirmed the impossible.  My Time Machine Backup was a whopping 1.15 terabytes worth of disk space.  “How in the world could the backup be so large?”, I asked myself.  “Time Machine is supposed to be an incremental system.  1.15 terabytes  is big enough to hold every bit and byte on my computer four and a half times over!”

First, I got annoyed; then, I got angry.  What really tipped the scale toward seething fury, however, was failing to find any straightforward way of getting the space back.  Yet another spectacular example of Apple’s “simple over useful” approach to computer design!

After the first bout of obscenities, I came to a simple conclusion: I could publicly express my dissatisfaction with Apple’s product line or I could go about trying to find a solution.  Publicly spouting off was unlikely to help much, so I opted for the latter option.  What follows is a brief summary of what I learned.

The Technical Details

The good news is that you can reclaim your drive space.  It’s not even very hard.  Here’s what you need to do:

  1. Delete any and all unnecessary backups from the sparse bundle image.  Time Machine is tremendously aggressive in making sure that you’re protected and while this might make sense for the near past, do you really need that backup from 9 months ago?
  2. Mount your AirDisk, Samba share or Time Capsule as a local drive.
  3. Use the hdiutil to compact the sparse bundle.

Step 1: Delete Backups from the Sparse Bundle

Start by loading Time Machine from the root of your main hard drive.  (In my case, the hard drive is named “RobOakes-Mac”.)  Next, select the snapshot that you are interested in deleting from the timeline at right.  Finally, press the gear button and select the “Delete Backup” option.

Time Machine - Delete Backups 1

Time Machine will ask if you want to proceed.  Confirm that you do, indeed, want to permanently remove the selected backup by pressing the “Ok” button.

Time Machine - Delete Backups 2

At this point – if you’re using Snow Leopard – you may run into a rather obnoxious bug.  For reasons that make little sense, the confirmation dialog box doesn’t always appear.  Instead, the user interface might freeze and you’ll be treated to the spinning beach ball of death.  If this happens, be patient.  It might take a minute or two for Time Machine to go about it’s business.  (Since this problem doesn’t exist on regular Leopard, go ahead and curse Apple’s grandiose, false, and self-serving rhetoric about parallelism.  It might even make you feel better, I know it helps me.)

When the damn beach ball finally goes away, just hit enter.  Apparently, the dialog box really is there, you just can’t see it.  So, use your imagination and pretend.

Finally, you will be prompted to enter an administrator password.

Time Machine - Delete Backups 3

When you’re all finished deleting snapshots, click on the main “Cancel” button.  This will take you back to your desktop.

Time Machine - Delete Backups 3

If everything worked as planned, you should see something similar to the screenshot below.  There will be a “Delete One Backup” indicator for each of the backups you removed.  Important: Wait for the indicators to finish before proceeding to the next step.

Time Machine - Delete Backups 4

Step 2: Mount the Disk Using Finder

Since we will be using a command line utility to compact the sparsebundle, you will need to mount your backup disk before proceeding.  While this can be done a variety of ways, the easiest is to open up the finder and select the backup drive from the list under “Shared”.  (When it is mounted, you will see a little eject symbol next to the computer name.)

Now open up a command line terminal and go to the /Volumes/ folder.

cd /Volumes/

Spend a bit of time looking in the various subdirectories until you find the correct .sparsebundle file.  The sparsebundle file will have the general form of Computername_MACaddress.sparsebundle.  Note the name of this file, it will be important in Step 3.

Step 3: Use the Command Line to Shrink the Sparsebundle Image

Once you’ve found your sparsebundle, use the following command to reclaim your free space (be sure to replace SparsebundleName with the name of your sparsebundle):

hdiutil compact SparsebundleName

Depending on just how your fat your Time Machine backup has gotten, this might take anywhere from a few minutes to a few hours.  Regardless, the good news is that it works!  After aggressively cutting away old backups, I was able to get my 1.15 terabyte porker down to a much more reasonable 500 gigabytes.

“An Ounce of Prevention”

While the procedure described above will let you fix the problem, it is far from an ideal solution.  For starters, it’s only a temporary fix.  Time Machine still has a gluttonous appetite for space and you’ll need to repeat the above steps whenever you want some of it back.  For me, that works out to every six months.  Further, the procedure is time consuming.  The obnoxious ui freezes, spinning beach balls, backup deletions, and sparse bundle shrinking requires more time than anyone should have to spend on this problem.

This is a clear case of “an ounce of prevention is worth a pound a cure.”  Rather than resorting to digital liposuction, it’s much better to simply limit how big the sparse bundle can become.  This is no more complicated than using the “-size” flag when you create it.  But if you (like me) overlooked that small step, then welcome to the club.  Let’s just hope that Apple implements a more intelligent way to managing Time Machine backup size in the relatively near future!


Similar Posts:

4 Responses to “Reclaiming Free Space from a Time Machine Backup”

Forest wrote a comment on December 21, 2009

Thanks for this Rob. I actually encoutered the same problem. The reason why the backup becomes so huge is that all files are added on the time machine hard disk. Those which are deleted from the mac are still kept on the backup drive. I think about those thousands of pictures that I write on my mac, of which I delete at least 30% of them. These 30% stay on the backup drive. Same story for songs. And not to forget the movies which I backup on my hard disk. I chose to exclude them from my time machine backup (this can be found in Options).

To conclude, as you mention, I think that Apple does its job right when it comes to ease of use. If their strategy allows it, their next version should include various options (for advanced users) like simple copy of certain directories, depth of backup (numbers of days of history, which reclaims hard disk space when backup is full, with a priority on old deleted files from the mac). I doubt very much about it: they might consider that it is cheaper for users to purchase large hard disk drives units then to spend time understanding, configuring time machine... and debugging their configuration... to finally loose some data because they are not skilled or because their setup became too complicated.

Kym Suttle wrote a comment on January 6, 2010

Hi Rob, I wonder if you can and are willing to help: I got burgled and my iMac desktop, 320GB, was stolen. The thief very kindly left my external hard drive that I was using for Time Machine so I still have all my data. I want to encrypt this external drive but I also want to delete old back-ups so that I have enough space to create an encrypted file on the external hard-drive. Here's the problem - I can't afford to replace my iMac just yet so I'm working on my MacBook which has a 120GB hard drive. When I plug my external hard drive into the MacBook I can't delete Timeline snapshot files as you describe because Time Machine doesn't register the backups because they were done on another computer. Because my MacBook only has 120GB I can't load the 320GB of backup from my iMac onto the laptop. Since I can see each Time Machine back up file on my external hard drive can I just delete the older files or will that affect the latest back up file?

I'm not technically minded so i hope this makes sense to you. Many thanks, Kym

Rob Oakes wrote a comment on January 25, 2010

Hi Kim,

I am sorry to hear about the trouble you've been having. There is nothing worse than having your computer stolen. A few years ago, I had my laptop stolen out of my bag. While I was lucky enough to get it back, I still had to go through the process of changing all of my passwords, cancel credit cards and notify friends/family that I lost their contact information. It was not fun.

While I personally haven't done much experimenting with it, there might be a way that you can prune your backup image. A Time Machine backup image is nothing more than a sparsebundle, which means that you should be able to mount it in the finder and navigate it like any other hard drive.

After you mount the sparse bundle, you will see a folder called Backups.backupdb. That folder holds all of the backups for your computer. They will be organized in folders according to date. You *should* just be able to delete the ones you don't want. Once that's finished, you can reclaim the space by following the directions in the article above.

Let me know if you have any questions.

Cheers,

Rob

Jed wrote a comment on April 1, 2010

Thanks for the info in this entry! I was looking for a way to compact the sparsebundle after deleting backups; sounds like hidiutil is just what I need.

Wanted to mention two things that might be of use to other people who come across this page:

1. In my experience, deleting multiple backups at once seems to take much much longer than deleting them serially. I haven't timed this, so it may just be an illusion, but for what it's worth, I do them one at a time. Which is a pain, because it means going into the Time Machine interface once per deletion, but I do think it's faster than deleting several at once.

2. Re Kim's problem: you can navigate backups belonging to other computers by first mounting the sparsebundle, then Control-clicking the Time Machine icon in the Dock, then selecting Browse Other Time Machine Disks. There are some odd things about the interface if you do that, but mostly it seems to work about the same as browsing the current computer's backups.