Best Reviews logo
Best Reviews may receive compensation for its content through paid collaborations. See how we sustain our work & review products.
How to Clean Up Time Machine Backups

How to Clean Up Time Machine Backups

By István F.István F. Verified by Adam B.Adam B. Last updated: December 4, 2024 (0)

One of the things you’ll love about your Mac – especially if you have recently switched from Windows – is Time Machine, the built-in backup feature. To use it you’ll need an external storage solution such as an external hard drive (or SSD) connected via the USB, Thunderbolt or FireWire port on your Mac, the Time Capsule or macOS server on your network, or the external hard drive connected to the AirPort Extreme base stations on your network. It is recommended that you back up before every major action, but as you start using the feature you’ll see that you don’t really need to back up your Mac on a daily basis. But that, of course, varies by user.

Understanding Mac’s Time Machine

Time Machine has its own scripts for housekeeping, but sometimes (such as when you see the “Time Machine could not complete the backup” error message) you may need to intervene to clean up space on your Time Machine drive. Space can always be saved on your backup if you delete junk, cache and temporary files before you back up the computer. That’s particularly true if you haven’t set up any exceptions in Time Machine preferences, and everything is saved, even applications.

Time Machine

Since every external storage device has its own physical limits, if you are going to keep that drive in the long run then it’s good to optimize your backups so that they occupy less space. For that it is possible to compress Time Machine backups, but before you start deleting and compressing backups you need to understand how Time Machine works.

Time Machine uses File System Event Store, a hidden log macOS keeps of changes made to the data on each HFS+ formatted drive or partition. But this won’t list every file that has changed; instead, it will list the directories affected. Time Machine uses this log to find out what’s changed and what needs to be backed up.

When Time Machine does the first backup, it copies everything (except trash and system work files) and creates a dated backup folder (year-month-day-hhmmss) in the Backups.backupdb folder, placing hard links in it to all the backup copies it has just made. Another dated backup folder is then created with the second backup, and this repeats each time. There is a trick, however: the second backup folder contains hard links to the items that remained unchanged.

How to compress Time Machine backups

There are notable differences between the normal (or local) Backups.backupdb folder and a backup made over a network. Local backups are stored in a single Backups.backupdb folder at the top level of the external hard drive.

If you are backing up your Mac over a network (be it wired or wireless), you’ll find the Backups.backupdb folder inside a container called a “sparse bundle disk image”. While it works just as well as the local backup version, an extra step is needed to actually recoup the space gained by deleting earlier backups due to its format. Unlike a normal folder or disk image, when you delete a file in a sparse bundle, it won’t change the container size. To recoup the space, run the following command in Terminal (replacing the ‘Yourbackup’ entry with the necessary backup name):

% sudo su - root
% hdiutil compact /Volumes/TimeMachine/YourBackup.sparsebundle

What you’ll then see is:

Starting to compact…
Reclaiming free space…
……………………………………………
Finishing compaction…
Reclaimed X.X GB out of XXX.X GB possible.

How to remove old Time Machine backups

1

Enter Time Machine.

2

Navigate to the backup you want to remove.

3

Right-click on the backup in the Finder window of Time Machine, and select Delete Backup.

40% Discount on CleanMyMac X
CleanMyMac X logo
Switch your current Mac optimizer or antivirus for CleanMyMac X, and the company will offer you a tasty 40% discount.
Save 40% on CleanMyMac X

Time Machine will prompt for the admin password and then delete the required file.
That’s a bit clumsy if you want to delete multiple backups, so here’s a Terminal command for this, which is very useful when deleting old backups:

tmutil delete /TimeMachine/Drive/Path/To/OldBackup/

Or, if you want to remove a backup from a specific date:

tmutil delete /Volumes/BackupDriveName/Backups.backupdb/MacComputerName/YYYY-MM-DD-HHMMSS/

How to delete old Time Machine backups automatically

If you don’t mind speaking with your Mac via Terminal commands, then it’s even possible to automate the removal of old Time Machine backups by running the following batch script. Note that this will find the oldest and newest backups and display a prompt to delete the oldest, which then requires you to enter “Y” and the admin password to finish.


COMPUTER_NAME=$(/usr/sbin/scutil --get ComputerName)
NBACKUPS=$(/usr/bin/tmutil listbackups |
/usr/bin/grep "$COMPUTER_NAME" |
/usr/bin/wc -l)
OLDEST_BACKUP=$(/usr/bin/tmutil listbackups |
/usr/bin/grep "$COMPUTER_NAME" |
/usr/bin/head -n1)
LATEST_BACKUP=$(/usr/bin/tmutil latestbackup)
echo Latest backup: $LATEST_BACKUP
if [[ -n "$LATEST_BACKUP" && "$LATEST_BACKUP" != "$OLDEST_BACKUP" ]] then
echo -n "$NBACKUPS backups. Delete oldest: ${OLDEST_BACKUP##*/} [y/N]? "
read answer
case $answer in
y*)
echo Running: /usr/bin/sudo /usr/bin/tmutil delete "$OLDEST_BACKUP"
/usr/bin/sudo time /usr/bin/tmutil delete "$OLDEST_BACKUP"
;;
*)
echo No change
;;
esac
else
echo "No backup available for deletion"
fi


Best mac optimization software of 2024

Editor's choice
CleanMyMac X logo
Editor's rating:
(4.5)
User-friendly dashboard
Effective scanning and cleaning options
Various maintenance tools
Built-in malware remover
All-around protection
MacKeeper logo
Editor's rating:
(4)
Personalized remote assistance
Unique optimization tools
Anti-theft tracking
Built-in antivirus
Beginners
MacBooster logo
Editor's rating:
(3.5)
Fast scanning
User-friendly UI
Virus and malware scan
Great cleaning features
Businesses
CCleaner for Mac logo
Editor's rating:
(4)
Fast scans and cleaning
Full customization
Extensive free version
Affordable
User Feedback

 Leave a reply

Your email address will not be published. Required fields are marked *


Best Reviews

Best Reviews may receive compensation for its content through paid collaborations and/or affiliate links. Learn more about how we sustain our work and review products.

©2012-2024 Best Reviews, a clovio brand – All rights reserved
Privacy policy · Cookie policy · Terms of use · Partnerships · Contact us