Skip to content

Instantly share code, notes, and snippets.

@unger1984
Created October 20, 2024 17:34
Show Gist options
  • Select an option

  • Save unger1984/7618705654606b2e293e2852d1dcaf98 to your computer and use it in GitHub Desktop.

Select an option

Save unger1984/7618705654606b2e293e2852d1dcaf98 to your computer and use it in GitHub Desktop.
Unmount external disk after TimeMachine end backup
#!/bin/bash
VOLUME=''
while true;
do
# Detect TimeMachine status
STATUS=$(tmutil currentphase)
if [[ "$STATUS" == "BackupNotRunning" ]]
then
# TimeMachine stop
if [[ "$VOLUME" != "" ]]
then
# TimeMachine and backup
diskutil unmountDisk "$VOLUME"
VOLUME=''
fi
else
# TimeMachine working
# Save backup disk path
VOLUME=$(tmutil destinationinfo | egrep '^Mount Point ' | sed 's#^Mount Point *: ##g' | head -1)
fi
sleep 10s
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment