[Server-devel] Need help: mounting usb devices on headless machines

James Cameron quozl at laptop.org
Thu Aug 7 02:52:42 EDT 2008


Don't know about Fedoristas, but on Debian and derivatives this is what
I do for a backup disk that is identified by UUID and then backed up to
... all when plugged in ... beep ... wait for rsync ... beep beep ...
pull it out.


/etc/udev/rules.d/010_local.rules:
# backup drive "a" 2008-05-02
# (activates on every new block device)
ACTION=="add", SUBSYSTEM=="block", BUS=="usb", RUN="/usr/local/bin/add-block-usb"

/usr/local/bin/add-block-usb:
#!/bin/sh
set -e

if [ -z "${ID_FS_UUID}" ]; then
    exit
fi

function backup {
        exec 2>&1 > /tmp/backup-${ID_FS_UUID}.log
        echo -en '\007' > /dev/tty1
        mkdir -p /media/backups/${ID_FS_UUID} 
        mount -v /dev/disk/by-uuid/${ID_FS_UUID} /media/backups/${ID_FS_UUID} 
        cd /a
        rsync --archive --verbose --delete-before \
            ${*} /media/backups/${ID_FS_UUID} 
        umount -v /media/backups/${ID_FS_UUID} 
        echo -en '\007' > /dev/tty1
        sleep 0.4
        echo -en '\007' > /dev/tty1
}

case "${ID_FS_UUID}" in
    2d1418da-0b75-4676-89a2-dae422ffa4f2)
        backup backups
        break
        ;;
    *)
        touch /tmp/backup-${ID_FS_UUID}.ignored
        ;;
esac

-- 
James Cameron    mailto:quozl at us.netrek.org     http://quozl.netrek.org/



More information about the Devel mailing list