+#!/bin/sh
+
+. /etc/triggerhappy/scriptenv.conf
+
+if [ -e $LAST_PRESSED ]; then
+ seconds=$(($(date +%s) - $(date +%s -r $LAST_PRESSED)))
+else
+ seconds=0
+fi
+
+if [ $seconds -lt 3 ]; then
+
+ beep -l 200
+
+ for dev in /media/usb*; do
+
+ if [ ! -L $dev ]; then
+
+ blkdev=`findmnt -nr $dev | awk '{ print $2; }'`
+ if [ "$blkdev" != "" ]; then
+
+ label=`blkid -s LABEL -o value $blkdev`
+ uuid=`blkid -s UUID -o value $blkdev`
+ if [ "$label" != "" ]; then
+ dirname="$uuid ($label)"
+ else
+ dirname="$uuid"
+ fi
+
+ dir="$DIR_BASE/$dirname"
+
+ echo $dev $dir
+ mkdir -p "$dir"
+ rsync -rv "$dev" "$dir" --exclude="lost+found"
+
+ fi
+
+ fi
+
+ done
+
+fi
+
+
+sync
+umount /media/usb*
+beep -l 500