Unable to Empty Trash and Delete Time Machine Backups? Here’s How to Fix That #Mac




Empty the Trash when Time Machine backups won't delete




Despite Time Machine being a remarkable solution for easy backups, a peculiar issue can arise for some Time Machine users that causes the OS X Trash to not be able to empty when the backup drive is connected to the Mac. This will usually manifest itself as the following; a user attempts to empty the Trash, the Trash either refuses to empty, or gets stuck on “Preparing to empty the Trash…” which then counts up to several hundred thousand (or more) files. Left alone, the Trash will sometimes start deleting after a few hours of counting the files, but it goes so slow that you can literally wait a day or more for the Trash to delete – hardly practical.




Infinitely counting Trash items when Time Machine backups are deleted




This is obviously a quirk or bug, and it seems to happen either when someone attempts to manually remove backups to create extra space on a hard drive, or when an ancient backup gets corrupted when Time Machine is attempting to perform housekeeping. This issue was was supposedly resolved in a past OS X update, but nonetheless it continues on in Mountain Lion and Mavericks, perhaps because the files that are causing the problem are often much older, typically from OS X Lion and before.




OK enough discussion of the problem and some background, let’s get to the solution so that you can empty the Trash can again and remove those old stubborn Time Machine backups once and for all.




Manually Empty Trash when Time Machine Backup Files are Stuck




This requires the use of force delete through the Terminal, which makes it a bit more advanced. If you don’t know what you’re doing or are not comfortable with Terminal you may want to skip this entirely and just wait out the incredibly lengthy Trash deletion through Finder instead. Proceed at your own risk.




Be sure to issue commands precisely otherwise you may unintentionally delete files you do not want to remove, this is very important because the Terminal does not prompt you for approval or confirmation, it simply deletes everything.







  • Connect the Time Machine drive to the Mac and (temporarily) stop any existing Time Machine backups



  • Open Terminal, found within /Applications/Utilities/ and then enter the following command to change the active directory to that of the Time Machine backup drive:





  • cd /Volumes/(backup drive name)/.Trashes/




    For example to change directory to a backup drive named “Mac Backups” the command would be:




    cd /Volumes/Mac\ Backups/.Trashes/






  • Confirm you’re in the proper location by listing the contents of the .Trashes/ folder, this will usually reveal a ’501′ subfolder, which contains the stubborn Backups.backupdb files. You can double-check you’re in the right place with sudo ls:





  • sudo ls 501/




    Note: Under some circumstances, the 501 folder will not exist, or it will be named something else. Sometimes .Trashes contains the backupdb files directly as well. If you do not find the 501/ directory, just delete the contents of .Trashes/ instead. We’re going to focus on .Trashes/501/ to be as verbose as possible with the intention on reducing errors with rm command.






  • Now to delete the contents of the .Trashes 501 folder using the rm command. Be sure to have the correct syntax in use here otherwise you may accidentally delete something you do not want. The rm command does not ask for confirmation, it simply deletes files.





  • sudo rm -rf 501/Backups.backupdb/




    Enter the administrator password when requested to begin deleting the .Trashes/501/Backup.backupdb/ files






  • Let the Terminal sit and do it’s thing, there is no visible activity but typically that files will be removed within 2-15 minutes at most, exit out of Terminal when finished



  • Confirm Trash is working as intended again by emptying it as usual in the OS X Finder






Advanced users only: shorter syntax version to Trash stuck Time Machine backups




A much shorter version of the above process can be achieved by eliminating some of the safeguards used in the above steps. Only use this command if you are comfortable with the Terminal, replacing “BackupDriveName” with the name of the hard drive in question:




sudo rm -rf /Volumes/BackupDriveName/.Trashes/*




Forcibly delete Time Machine backups from the Trash




If the reason you are attempting to delete old backups is to free up space for other media, consider partitioning the backup drive so that a section is devoted to Time Machine while the rest is available for direct file storage. This will prevent the need to manually remove the Time Machine backups in order to make room for files and hopefully prevent this issue from ever arising at all.




Additionally, keep in mind that if you use redundant Time Machine backups you may need to perform this process on both backup drives.




Thanks to Max H for the tip idea

















source



source