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?
Best Answer
Ive always done mine based on user login. You would go to Users & 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:
Some links to mounting:
You could do through a
LaunchAgent
here are some resources: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.