pablitobs,
It's probably not a good idea to try and mount a removable disk on a perminent file system.
What I do is let users store stuff in an Ibay on the file system and then sync that Ibay with a removable disk.
In fact most of my clients have a laptop drive in a casing and plug it in when they get to work and take it with them when they leave. I have a cron job which runs every 15 minutes and syncs /home/e-smith/files with the USB disk. They get an off site copy of the data including email if you run imap.
Here is the code I run :
##<START>***************************************************************
#
#!/bin/bash
#
#
# BACKUP TO USB
#
#
ADMIN_EMAIL="admin"
# Ensure the device is plugged in
if [ ! -b /dev/sdd1 ]; then
exit 1
fi
# Ensure the script isn't already running
if [ -f /var/run/backuptousbdrive.sh.pid ]; then
PID="`cat /var/run/backuptousbdrive.sh.pid`"
for i in `ps x | grep backuptousbdrive.sh | sed 's/^ *\([0-9]*\).*/\1/g'`; do
if [ "$i" == "$PID" ]; then
exit 2
fi
done
fi
echo $$ > /var/run/backuptousbdrive.sh.pid &&
# Create Temp Directory for backup
mkdir -p /tmp/usbdisk &&
mount -t auto /dev/sdd1 /tmp/usbdisk &&
sync
# perform backup
###########################
#
#
mkdir -p /tmp/usbdisk/home/e-smith/files
rsync -ar --delete-after /home/e-smith/files/ /tmp/usbdisk/home/e-smith/files 2>&1
#
#
############################
# wait a few seconds to make sure the disk is no longer being used
sleep 5
if [ "$?" == "0" ]; then
SCRIPT_MESSAGE="Backup completed successfully."
touch /tmp/usbdisk/timestamp
else
SCRIPT_MESSAGE="Backup failed. To retry, please remove the drive, wait 10 seconds, and re-insert"
echo $SCRIPT_MESSAGE | mail -s "USB BACKUP FAILED $?" $ADMIN_EMAIL
fi
umount /tmp/usbdisk
rm -rf /tmp/usbdisk
rm /var/run/backuptousbdrive.sh.pid
# END
##<END>*****************************************************************
I know it's not perfect and yes I don't get emails from the script, I get emails from cron when they pull out the drive during a sync or worse. Also it does not remove files from the USB disk, so the disk will fill up and overflow, but that's what service agreements are for
man sync and you can make exclude files to piss off tmp files or directories you don't want to capture.
Generally it works well for me and I show the USB disk as /dev/sdd1 in this script. Yours may differ.