I have a set of hard drives which are rotated for offsite backup. There are several steps that need to be performed when one of the disks is reinserted which I've rolled into a simple bash script. I'd like to execute the script automatically when one of the disks is hot-swapped in.
Ideally I'd have a list of disk-id's (/dev/disk/by-id/...
) for the disks which should trigger the script; when one of them is inserted the script would be ran and the ID of the specific disk would be passed in as a parameter. As an alternative it would be good enough to have a copy of the script per-disk and have each script ran for its respective disk.
I'm running Ubuntu Server 14.04 LTS, and have been skimming similar questions related to USB drives and am looking at udev
and hotplug
as the two systems that I'll likely need to use, but was hoping someone may be able to point me to a specific succinct solution for my needs.