[lug] Automated USB Drive Backup

Lee Woodworth blug-mail at duboulder.com
Fri Oct 26 00:37:11 MDT 2007


karl horlen wrote:
> I've never used a USB external drive with linux
> before.  
> 
> I'd like to create some rsync scripts to backup
> directories to the external drive.  Manual scripts are
> pretty straightforward. However, I'd like to be able
> to automate the process so that the script fires when
> the drive is plugged in.
> 
> I'm wondering if current distros are capable of
> automounting and autoUNmounting these external drives
> RELIABLY when plugged in and removed.
> 
> Is this functionality available in most stock installs
> or do you usually have to post install rpms?  If rpms,
> which one(s)?  FYI, I'm using CentOS but am curious
> about how other distros handle this as well.
> 
> I imagine this is triggered by an fstab parameter?
> 
> On linux can you just unplug the drive or must you
> "prep" it before doing so to prevent data loss? 
> Normally on windows based systems you have to manually
> "stop" the drive before you remove it, probably to
> write out buffers or cache or something.
> 
> Does an automount "event" or some other method exist
> that I could capture in a script to trigger the
> backup?    I could setup up a cron job to poll and
> check if the drive on the mount point was available
> but I would need a way to prevent the backup job from
> continuously re-firing on each iteration of the cron
> job while the drive is plugged in.  It can be done but
> I thought the ability to capture a single event would
> simplify this.
> 
> Would succesfully implementing this have any bearing
> on what type of filesystem I put on the drive?

udev can trigger events when a disk is plugged in. Other people
can tell you more about how to use it. For linux, you do need to
unmount a usb disk before unplugging it. For m$ the usual
removable device fs is some version of fat, which usually doesn't
self destruct when a device is unplugged w/o using the
'safely remove hardware' function.


man 7 udev

NAME
       udev - dynamic device management

DESCRIPTION
       udev provides a dynamic device directory containing only the files for
       actually present devices. It creates or removes device node files in the
       /dev directory, or it renames network interfaces.

       Usually udev runs as udevd(8) and receives uevents directly from the
       kernel if a device is added or removed from the system.

       If udev receives a device event, it matches its configured rules against
       the available device attributes provided in sysfs to identify the device.
       Rules that match may provide additional device information or specify a
       device node name and multiple symlink names and instruct udev to run
       additional programs as part of the device event handling.





More information about the LUG mailing list