Created
October 20, 2024 17:34
-
-
Save unger1984/7618705654606b2e293e2852d1dcaf98 to your computer and use it in GitHub Desktop.
Unmount external disk after TimeMachine end backup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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