Mac – How does Time Machine behave when the backup drive becomes full

time-machine

Let's say I have a particular folder, that has never changed, in the first backup, eg my MP3 music collection from 2009. (I know my important files should be saved elsewhere, but it's just an example).

In one scenario, I deleted the folder, and in another, the folder is still in my home folder.

I dont understand what this means: The oldest backup are deleted when your disk becomes full.

Does it means that when there is not any space left on the drive, Time Machine will start deleting my music ?

Obviously if there is no more space left and Time Machine wants to backup new files, it has to delete something. But what exactly does it delete ?

Best Answer

Roughly speaking, Time Machine deletes files in the same order you do. (The roughly speaking part has to do with it deleting hourly backups even when there are older daily backups, and daily even when there are older weekly backups.)

For example, suppose you create a file in January and delete it in July, and TM is backing up all this time. TM will first see and back up the file in January. From then until you delete the file in July, every time TM does a backup it notices that you have the file but it's already backed up, so it doesn't copy it again. It does, however, put it into every single one of those snapshots. How it does that without copying the file again is fascinating but not important here. The point is, the file is in every one of those snapshots, and won't be deleted until all of them are. Unless you're micro-managine TM, that won't happen until the disk is so full that TM has had to delete everything thru July.

Another way to say it: Even though it copied the file only once, it saw it many times, and won't delete it as long as it remembers any of those sightings.

More precise rules:

Time Machine does not backup any file it has never seen. (Duh!) If you create a file and immediately delete it, before TM takes its next snapshot, it doesn't get backed up. This can be summarized as If you don't keep it, neither does TM.

Time Machine defines an hourly backup as any snapshot that is not the first snapshot of its day. It deletes it when it is 24 hours old, or when you've used "Backup now" to force 24 newer hourly backups after it. If you create a file, keep it around until TM takes at least one snapshot (let's call it an hour) but delete it later that same day (or at least before the first snapshot of the following day), TM will keep it for 24 hours. This can be summarized as If you keep it for an hour, TM keeps it for 24 hours.

Time Machine defines a daily backup as the first snapshot of a day that is not also the first day of the week. TM will keep it for a month. This can be summarized as If you keep it for a day, TM keeps it for a month.

Time Machine defines a weekly backup as the first snapshot of the week. Rather than get into a religious war about when a week begins, TM defers the decision of whether a snapshot is a daily or a weekly backup until the snapshot is at least a month old. Until then, it doesn't matter, because it'll keep it either way. When a snapshot becomes more than a month old, if there is another snapshot less than 7 days prior, then the newer one is a daily backup, and gets deleted. Otherwise it's a weekly backup and gets retained. This can be summarized as If you keep it for a week, TM keeps it until the disk is full.

By the above rules, your initial backup is therefore on the first day of its week, no matter what day that is. Successive "weeks" will be at least 7 days long, and may be longer if you don't let TM make regular backups.

TM is in effect watching what you do with the file to see how aggressively it should preserve it. The longer you keep it before deleting it, the longer TM keeps it before deleting it. Your actions give TM guidance how to put your files into one of four classes: files you deleted before TM saw them, files you deleted before the next day's first snapshot, files you deleted before the next week's first snapshot, and files you kept across a weekend. These groups have successively longer retention periods, matching the fact that they contain files you kept for successively longer times before deleting them.

In each group, TM backs up the files in the same order you created them, and deletes them in the same order you deleted them.

TM never deletes your only snapshot. If it has deleted all but one snapshot to make room, and still does not have enough, it will abort the backup. It's better to have an old backup than none at all. This can be summarized as If you never delete it, neither will TM.