10

I have moved from a Mac running Snow Leopard to a new Lion machine. Since there was a lot of cruft on the old machine, I set up the new one from scratch, only copying the data over I need. I still want to retain the Time Machine backup of my old machine for a while in case I missed something. That backup spans many months though and is huge. I really just need the latest backup from it, not its whole history.

Is it safe to simply open the Time Machine sparsebundle in Finder or on the CLI and remove the oldest folders? Or should I be using some Time Machine interface or tool to do so? I don't want to do it via the Starfield view, since it'll take me ages to click back and forth and delete each backup individually.

bmike
  • 235,889
deceze
  • 1,352
  • 4
  • 14
  • 27

4 Answers4

10

tl;dr - It's safe to delete in whatever way you choose.

The only conceivable problem would be if Time Machine was trying to prune a backup at the same time you were deleting, so maybe turn off Time Machine for the duration of your clean up if you're not using the built in delete button.

enter image description here


You can use tmutil delete in Lion to safely delete backups. The benefit of this is the deletion happens more silently in the background. The downside is the UI isn't speedy for deleting more than one snapshot at a time. In practice, you have to be there to attend multiple deletions.

Don't worry about the internals of how files are linked or stored - yes most of the files in most of the backups are hard links, but to clean these up, you have to delete things folder by folder. The system will handle decrementing the link count so there's no better or worse way to go here.

It is also safe to simply remove them via Finder or any other method - just be patient as each backup contains a full set of directory entries for each file. My (worst) record is 4 days to delete through finder a batch of unwanted backups.

Good advice might be to start small if you can't leave your mac on overnight.

You won't lose any data unless you are deleting the last copy of a version of some file. You don't get any warnings, it will get deleted - this is the same whether you use Time Machine itself, or Finder or rm in some terminal script.


As a brief aside - Why do you want to do this? Time Machine automatically prunes old backups when you're getting low on space. I've found it very comforting to just clone my Time Machine drive to a cheap USB external drive and put it on the shelf. (or make this the drive on the shelf and use it as an excuse to get a new drive) Perhaps it's the perfect pack-rat-keep-everything verses if-you-don't-need-it-now's-the-time-to-delete-it test for Mac users.

jtbandes
  • 11,074
  • Just to confirm, Lion's tmutil would correctly handle Snow Leopard backups as well? As I said, the old machine doesn't exist anymore, but I want to keep its backup. This backup will not be pruned automatically anymore, because no machine is actively using it anymore. I don't have enough room to backup my new machine though since the old backup is taking up too much room. – deceze Aug 03 '11 at 06:44
  • I can't imagine it would handle SL backups incorrectly, but I won't make any guarantees. After reading some more, I'm not sure if it's safe to just delete them from Finder. – jtbandes Aug 03 '11 at 06:57
  • 3
    I'm going to edit @jtbandes answer fairly heavily - there is absolutely no wrong way to delete these files. Yes time machine or a shell script using rm may be faster and not tie up your Finder for hours or days, but it's really up to user preference. Whether you delete a hard link or the last copy of a file, any delete does the same thing in the end. The new tmuitl is perfectly fine for deleting any version of Time Machine backups. – bmike Aug 03 '11 at 14:17
  • Thanks, bmike — if you're sure it's safe, I'm happy to have that info in my answer :) – jtbandes Aug 03 '11 at 15:30
  • "whatever way you choose" does not seem to be true: when not using tmutil then deleting nested directories might affect OTHER backups, due to how hard links work. See How can I delete Time Machine files using the commandline on Super User. – Arjan Sep 10 '15 at 06:16
6

Time Machine has supported deleting snapshots from Finder since 10.7:

Like tmutil delete, it only works with the directories for complete snapshots though.

I don't know why it's not allowed normally, but you can delete individual files with something like sudo /System/Library/Extensions/TMSafetyNet.kext/Helpers/bypass rm -rf /Volumes/Time\ Machine/Backups.backupdb/Macintosh/2012-10-04-033043/HD/tmp.

Hard links don't stop working when the original files are removed:

$ echo x > 1; ln 1 2; rm 1; cat 2
x

There's another similar question at Super User.

Lri
  • 105,117
3

You are OK to go ahead and delete the older backups using the Finder. Just beware that any files that only exist in these backup periods will be gone. Deleting backups on command doesn't preserve files or merge/combine backups like the normal Time Machine pruning does in an effort to keep as many files available on the backup as possible.

Time Machine BackUp view through Finder

bmike
  • 235,889
Slick
  • 1,051
  • I STRONGLY don't advise this method. Due to the nature of incremental backups, slight changes made to the files within the deleted timeframe will cause other change to not be enough to complete the file. – Alexander Aug 03 '11 at 08:45
  • FILES THAT HAVE BEEN BACKED UP WITHIN THE DELETED TIMEFRAME WILL BE UNRECOVERABLE WITH TIME MACHINE. i just felt like i should repeat lol – Alexander Aug 03 '11 at 08:46
  • 1
    I thought this wasn't true because of the way Time Machine uses hard links. Am I wrong? – jtbandes Aug 03 '11 at 09:03
  • 2
    Indeed, I believe @XAleX is wrong, since files are always saved as a whole. The only incremental thing about Time Machine backups is that all unchanged items are hard-linked and are not stored twice. AFAIK. – deceze Aug 03 '11 at 09:32
  • So if you don't agree with this method then we would be happy for you to provide a solution to the question above. – Slick Aug 03 '11 at 09:33
  • @slick BTW, can you please clarify your last sentence? "beware that files backup in those periods will be gone aswell" Sure, if I remove the backups the files in those backups will be gone, obviously. :) Do you mean anything beyond that? – deceze Aug 03 '11 at 09:54
  • @deceze, No thats exactly what I meant. Just to be sure that everyone knows what exactly they are doing before they delete their backups. – Slick Aug 03 '11 at 10:42
  • It sounds to me like ANY manual deletion of Time Machine backups runs the risk of you being left with some current files that do not have a backup anywhere in your backup set. I'd suggest testing very carefully, including very likely performing a fresh backup immediately after performing the deletions to give TM a chance to add missing files back in. – David Aug 03 '11 at 11:49
  • I'm going to edit this as well. When a human deletes a snapshot - no merge happens. Time Machine does take pains to merge a singleton file when it is pruning intermediate backups. You will lose any files where the link count is 1 when deleting (i.e. when you delete the last copy of that file on the TM archive) – bmike Aug 03 '11 at 14:25
  • @bmike I always wondered about that point. When Time Machine cleans old backups, it actually tries to create a merged backup that contains all files? E.g., when deleting daily backups to reduce them to weekly backups, that one weekly backup will contain all files that were in all the daily backups, not just the files in the latest backup of that week? Basically, it's creating a superset of all daily backups of that week? That means that if I delete old backups in the Finder except one, I will have all files of that point in time, but no more (which is all I need)? – deceze Aug 04 '11 at 02:43
  • Think of it more like a file that was only on the 3pm and 4 pm backups will get merged forward to the daily backup, even if it wasn't there on the mac early in the am. To ensure a file once backed up makes it at least a month. I'm not 100% sure the merging happens when the dailies move to weekly, but don't see why not. – bmike Aug 04 '11 at 04:03
0

I would recommend against using Finder to delete backups, however it is certainly possible from inside Time Machine itself. When you're in Time Machine, navigate the window to the Computer setting, in the sidebar it should be the name of your computer. When that is the active window, the "Gear" icon on the toolbar changes its functionality. Go "back in time" to the date that you don't want any more and click on the Gear icon. Select "Delete Backup" from the menu and enter your administrator password if prompted and let Time Machine do its thing. This allows Time Machine to update its database and keep the links it makes intact.

bringel
  • 780
  • Thanks for your answer, but as I said, this would take me the better part of the day to finish, as it's a terrifically sluggish way to delete more than one backup. And, I believe, the backup is basically deleted normally through the Finder anyway in the end. – deceze Aug 03 '11 at 22:42
  • Wow sorry, didn't read the question all the way to the end I guess. Oops – bringel Aug 04 '11 at 02:52