I'm currently writing my thesis at a big company, with an even bigger corporate firewall. So I've to save my work on an USB flash drive. Now I'm searching for a backup solution for that flash drive and don't want to do this manually. Does somebody know how to run a program / bash file when this specific USB device id connects to my computer so I can automate the rest of the process?
Create a LaunchDaemon (if you want the script to run independently of who's logged in) or LaunchAgent (if you want it to run inside the current user's session), with the StartOnMount key set to true. The script will be run anytime any volume mounts, so you'll need to start the script with something to detect your particular drive -- it could check by name (i.e. look for "/Volumes/My Backup Drive"), by a contained file (look for /Volumes/*/.backupTarget), or whatever. If you want some sort of hardware ID, your best bet is probably the