Apple - How to wipe huge .MobileBackups folder?
To disable local backups issue this command in terminal:
sudo tmutil disablelocal
This almost never is necessary as the system will automatically prune and disable local backups as your drive fills. You can search for backupd using the console app to see if and when the storage cleanup happens due to low space.
There is a lot of confusion as to the purpose of local snapshots. It's not to take snapshots that then get dumped to your actual Time Machine drive when you run a backup, it's a separate set of snapshots that let you restore files you've accidentally changed or deleted, when you're away from your Time Machine drive. It's not a true backup -- it won't help you if your laptop's drive fails -- but it will help out if you're on the go and you accidentally lose something while on the go. As such, they don't get cleared out after TM backups.
On my computer (a Macbook Air with flash memory), it deletes old mobile snapshots after a week. The behavior may be different on devices with hard drives, as they don't experience longevity issues with full disks. According to Apple's documentation, they aren't deleted after a week. Note that the available space shown in Finder does not take into account the local snapshots, because they will automatically be deleted if you need the space, and it will automatically keep at least 20% of your disk space free -- so you generally shouldn't worry about space taken up by local snapshots.
However, if you don't want them around, you can disable them with the command sudo tmutil disablelocal
. This will free up the space taken by your local snapshots, and if you reenable it with sudo tmutil enablelocal
, it'll start again with an empty set of local snapshots. So, a quick way of clearing out what's on there is to disable and re-enable local snapshots.
You can see how many old backups are being stored by activating Time Machine. White tick marks indicate local snapshots, and purple ones indicate real backups.
There's more information from apple and here.
I'll add to this, since I had the issue of migrating data from a 1TB HDD to a 0.5TB SSD via Time Machine Restore. I had slimmed down the total data on the disk from ~730GB to ~350GB, but still was seeing that the Time Machine Backup was at the ~730GB size, due to the Mobile Backups.
Turning Time Machine off will delete Mobile Backups, but that isn't done immediately (and can be confirmed in Disk Utility)—they are simply moved to the Trash to be deleted later (although you won't see them). Some would suggest the drastic measure of using this Terminal command:
$ sudo rm -rf /.MobileBackups.trash
I would only recommend this as a last-ditch effort.
Since my data was backed up, I could try it, but was presented with permissions errors, presumably by the system as a type of safeguard. So, I stopped the process, and just did multiple system restarts.
This did the trick, and the space was freed up, allowing me to create a smaller Time Machine backup to restore to the smaller drive.