Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to automate backup with rsync to an external hard disk. What I want to do is to execute this command automatically when external hard disk is plugged. I do not want to run it when other hard disk or flash drive is plugged in. Can some please point me in the right direction. I am using Ubuntu 12.10.

Here is the command which I am planning to use.

rsync -arLth --progress --exclude-from '/home/user1/.backupExclude' /home/user1 media/user1/T500Backup/

and here is my .backupExclude file

user1@SCAR:~$ tail ~/.backupExclude 
share|improve this question

migrated from Dec 23 '12 at 2:24

This question came from our site for professional and enthusiast programmers.

You can do this with udev, i don't remember exactly how. – Jonathan Tribouharet Dec 23 '12 at 0:55
Definitely check out udev. – Linuxios Dec 23 '12 at 1:09
Actually, using udisks is a better abstraction for this, listen for events on system dbus. – Keith Dec 23 '12 at 1:58
Run udisksctl monitor to see what events you get and what info there is, such as drive number. – Keith Dec 23 '12 at 2:50
@Keith: This is awesome. I can use ID or serial#. But how, that is the big question. Others mentioned udev. I am still trying to figure out how I can use it. – nik Dec 23 '12 at 3:38

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.