How do I run a terminal script when mounting a specific disk? I have rsync set up, I have set up rsync as a UNIX executable and named the bash script as 'backup' and I saved it to /usr/local/bin so whenever I type backup in terminal it would do a backup to my external disk. But I want it setup in such a way whenever I plug in that drive it would run that bash script. I have already googled this but it doesn't work with High Sierra.
Ok as per all the suggestions the users gave I googled and found a nice .plist file:

&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST 1.0//EN http://www.apple.com/DTDs/PropertyList-1.0.dtd &gt;
&lt;plist version="1.0"&gt;
&lt;dict&gt;
    &lt;key&gt;Label&lt;/key&gt;
    &lt;string&gt;com.company.popup&lt;/string&gt;
    &lt;key&gt;ProgramArguments&lt;/key&gt;
    &lt;array&gt;
        &lt;string&gt;sh&lt;/string&gt;
        &lt;string&gt;-c&lt;/string&gt;
        &lt;string&gt;/usr/local/bin/backup&lt;/string&gt;
    &lt;/array&gt;
    &lt;key&gt;StartOnMount&lt;/key&gt;
    &lt;true/&gt;
&lt;/dict&gt;
&lt;/plist&gt;`


I have put this code under ~/Library/LaunchAgents and runs at login.Thanks for all your replies again it helped me find a better code.