backuppcExportOnUsbDisk/run-bkp-usb

42 lines
822 B
Text
Raw Permalink Normal View History

2017-02-28 15:13:49 +01:00
#!/bin/bash
FILE=/var/run/bkp-usb-detected
function usage () {
[ -n "$1" ] && echo -e "$1\n"
echo "Usage : $0 [device]"
echo " device To manually run export, provide the USB Drive device path"
[ -n "$1" ] && exit 1
return 0
}
2017-02-28 15:13:49 +01:00
function exit_error () {
[ -n "$1" ] && echo "$1"
2017-02-28 15:13:49 +01:00
beep -f 300 -l 2000
rm -f "$FILE"
exit 1
}
# Manually run
if [ -n "$1" ]
then
[ "$1" == "-h" ] && usage && exit 0
DEVICE="$1"
[ ! -b "$DEVICE" ] && usage "Invalid device '$DEVICE'"
echo -n "$DEVICE" > $FILE
exit 0
fi
2017-02-28 15:13:49 +01:00
[ ! -e "$FILE" ] && exit_error "File $FILE does not exists !"
DEVICE=$( cat "$FILE" )
[ ! -e "$DEVICE" ] && exit_error "Device '$DEVICE' does not exists !"
echo "Removing $FILE"
rm -f "$FILE"
echo "Run backup on device '$DEVICE'"
/usr/local/sbin/backup-usb -u "$DEVICE" -l /var/log/bkp-usb.log &
exit 0