Skip to content

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

eject-tm

Automatically ejects an external disk after a Time Machine backup completes — no polling, zero CPU idle.

How it works

A launchd user agent watches /Library/Preferences/com.apple.TimeMachine.plist for changes (which macOS writes at the end of every backup). When it fires, the script checks tmutil status to confirm the backup is truly finished, waits briefly for backupd to let go of the disk, then ejects it via diskutil eject. It retries for about 10 minutes, aborting early if a new backup starts, and falls back to a forced unmount if everything else fails. A macOS notification is sent on success or failure.

Spotlight

The most common cause of "could not eject — files in use" is Spotlight: mdwrite keeps the backup volume open and dissents the unmount, sometimes for hours. install.sh detects this and offers to turn indexing off for the chosen volume. To do it by hand:

sudo mdutil -i off -d "/Volumes/Your Backup"
sudo mdutil -X  "/Volumes/Your Backup"

Backups aren't searchable via Spotlight anyway, so there's nothing to lose.

Install

./install.sh

You'll be shown a numbered list of mounted volumes — just pick the one to eject. The script is installed to ~/Library/Scripts/ and the launchd agent to ~/Library/LaunchAgents/. Re-running install.sh upgrades an existing install in place.

Verify it's running:

launchctl list | grep eject-tm

Uninstall

./uninstall.sh

Logs

tail -f ~/Library/Logs/eject-tm.log

Test

tmutil startbackup
tail -f ~/Library/Logs/eject-tm.log

The disk will eject automatically when the backup finishes and a notification will appear.

Requirements

  • macOS (tested on macOS Sequoia)
  • Time Machine configured with an external disk

About

Automatically eject a Time Machine disk after backup completes

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages