Check automatically if a drive is mounted I'd like to automate my family backups, specifically I'd like to run a shell script (with rsync) when an external drive is connected.

Since it's a family thing, it should be also sort of GUI driven, maybe an icon like Dropbox. Probably a shell script with fswatch isn't really nice to play with, they would probably complain and certainly won't understand if an error occurs.

I was thinking about Automator or AppleScript (I have the GUI for the backup script in AppleScript already, but no automation), since "Folder Actions" isn't available for /Volumes, but any other solution is more than welcome.

Any suggestions?
Ive always done mine based on user login. You would go to Users &amp; Groups click the current user go to Login Items hit the plus icon at the bottom and you can add it there. I built a similar application to detect my NAS and mount if not mounted:



Sample code, not tested:

on run
    tell application "System Events" to set theDisks to name of every disk
    set theNAS to "Shared" ## Change here to name
    set isMounted to false
    if theNAS is in theDisks then set isMounted to true
    if isMounted = false then mount volume "afp://" &amp; theNAS
end run


Some links to mounting:


How can I mount a volume in a network?
Automated volume mounts on mac


You could do through a LaunchAgent here are some resources:


Run a script at login for all users
Applescript Login Item for All Users
Launch login items for all users at startup


There are other approaches like a launchd but you will sacrifice RAM so it can check. I think at login would be your best approach.