Let's look at a typical problem: I have a back-up hard drive. I used to back up my home directory everyday in this hard disk. This is normally done manually so, again, let's use udev to automate the procedure. Again, as we did with the EVDO modem, first plug in the external hard drive. Then run dmesg to identify the device. The following is the dmesg output in my case: Now, collect suitable keys to match the device using the following command:
Now formulate a matching rule as the following and write to a rule file [we'll call it/etc/udev/rules.d/lOObackupdisk. rules ]: We have an action script /usr/bin/backup, which is called when a match is found. Write a bash script with the following contents: Notice thafthe script mounts the external disk under /
mntlbackup. So, make sure you create that directory as well. Following this, make the script executable as follows:
That's it! Now, every time you connect the external disk, it starts the back-up procedure using rsync automatically. Once the procedure ends, you will get a pop-up notification on your desktop as well. You can tweak around a bit to make this back-up drive encrypted as well. However, I'll leave you to try it out yourself. So, that's all for now. Have fun with udev, and happy hacking!




Reply With Quote
Copyright Techfuels
Bookmarks