https://github.com/brianhenryie/unmountvolumeaftertimemachine
Automatically eject USB drives after TimeMachine backup finishes
https://github.com/brianhenryie/unmountvolumeaftertimemachine
backup-utility time-machine
Last synced: 6 months ago
JSON representation
Automatically eject USB drives after TimeMachine backup finishes
- Host: GitHub
- URL: https://github.com/brianhenryie/unmountvolumeaftertimemachine
- Owner: BrianHenryIE
- License: mit
- Created: 2023-06-12T02:05:06.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-09-05T19:26:29.000Z (about 2 years ago)
- Last Synced: 2025-03-29T23:41:15.990Z (7 months ago)
- Topics: backup-utility, time-machine
- Language: Swift
- Homepage:
- Size: 218 KB
- Stars: 14
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Unmount Volume After Time Machine
Automatically eject USB disks after Time Machine backup completes.
Launches when a USB disk is inserted and exits after Time Machine completes.
To avoid:

Quickly install via [yonaskolb/Mint](https://github.com/yonaskolb/Mint) – _A package manager that installs and runs Swift command line tool packages._
```
brew install mint
mint run BrianHenryIE/UnmountVolumeAfterTimeMachine
```
```
mint uninstall BrianHenryIE/UnmountVolumeAfterTimeMachine
```***
Originally requested as a feature for [nielsmouthaan/ejectify-macos](https://github.com/nielsmouthaan/ejectify-macos/issues/19) but not implemented in that now-archived project.
Uses [BrianHenryIE/SwiftTimeMachine](https://github.com/BrianHenryIE/SwiftTimeMachine) and [BrianHenryIE/BHSwiftOSLogStream](https://github.com/BrianHenryIE/BHSwiftOSLogStream) to parse Time Machine logs and query `tmutil` for status. When the backup job completes, the disk is ejected with `DADiskUnmount`.
TODO:
* ~~App should [run when disk plugged](https://apple.stackexchange.com/a/13724/299117) in / Time Machine starts and quit when the disk is ejected~~ [emorydunn/LaunchAgent](https://github.com/emorydunn/LaunchAgent)
* ~~When the app launches upon a disk being inserted, it should exit quickly if the disk is not used for Time Machine~~
* What happens the app tries to unmount after Time Machine but other files are being copied in Finder?
* Disks should be re-mounted as per the Time Machine schedule
* Some sort of UI/checkbox to enable/disable/communicate the app is present and running [apple/swift-argument-parser](https://github.com/apple/swift-argument-parser)
* [Notifications](https://github.com/dataJAR/Notifier) when the disk is ejected
* ~~Make available via [brew](https://docs.brew.sh/Formula-Cookbook)~~
* Currently, a race condition is possible that would cause the app to exit after another disk was unmounted (tiny window, fraction of a second)
* Check is the app already runningBuild and run
```
swift build -c release
./.build/release/UnmountVolumeAfterTimeMachine
```