Ninetynine is a creative design & coding agency

Archive for the ‘usb drive’ tag

Ubuntu: backup to USB drive on mount

with 9 comments

Hi everyone,

I always was sloppy with my backups and I really needed to do something about it. I bought a new Freecom HDD 500GB and what I wanted to do is quickly backup my files every time I plug the device in, and it should give me a proper notice when the backup is done.

Doesn’t sound that hard, or does it?

It became clear that I needed a little thingy called “udev”. And with big help from unutbu from ubuntuforums.org I managed to get a very nice script up and running.

First thing you have to do is to know how your system recognizes your USB drive.

I followed this great tutorial here. (Don’t bother the fstab!)

My rules look like these.

1
2
 
SUBSYSTEMS=="usb", KERNEL=="sd?1", ATTRS{product}=="Freecom Network Drive", NAME="freecomHD", RUN+="/usr/bin/usb_backup.sh"

Note that I have saved them under “/etc/udev/rules.d/81-local.rules”, because /etc/udev/rules.d/README says. It would also be safer I you select your device using UUID.

Files should be named xx-descriptive-name.rules, the xx should be
chosen first according to the following sequence points:

80 rules that run programs (but do not load modules)

After adding your rule, you need to restart udev.

$ sudo /etc/init.d/udev restart

Next install libnotify-bin through synaptic. This will make it possible for us to show notifies as if it were GNOME itself ;)

Next we’ll need to hack the script a little bit:

Read the rest of this entry »

Written by ruben

March 25th, 2009 at 12:37 pm

Posted in Ubuntu

Tagged with , ,