From 0ca55d33baa2ae591b3301d93c86968e93e1d4a4 Mon Sep 17 00:00:00 2001 From: Dmitri Popov Date: Fri, 16 Mar 2018 11:44:54 +0100 Subject: [PATCH] Use internal storage for backup --- gphoto-backup.sh | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/gphoto-backup.sh b/gphoto-backup.sh index 9aab077..7de1c90 100644 --- a/gphoto-backup.sh +++ b/gphoto-backup.sh @@ -1,26 +1,14 @@ #!/usr/bin/env bash # Specify a storage device and its mount point -STORAGE_DEV="sda1" -STORAGE_MOUNT_POINT="/media/storage" +STORAGE_MOUNT_POINT="/home/pi/BACKUP" # Set the ACT LED to heartbeat sudo sh -c "echo heartbeat > /sys/class/leds/led0/trigger" -# Wait for a USB storage device (e.g., a USB flash drive) -STORAGE=$(ls /dev/* | grep $STORAGE_DEV | cut -d"/" -f3) -while [ -z ${STORAGE} ] - do - sleep 1 - STORAGE=$(ls /dev/* | grep $STORAGE_DEV | cut -d"/" -f3) -done - -# When the USB storage device is detected, mount it -mount /dev/$STORAGE_DEV $STORAGE_MOUNT_POINT - -# Set the ACT LED to blink at 1000ms to indicate that the storage device has been mounted -sudo sh -c "echo timer > /sys/class/leds/led0/trigger" -sudo sh -c "echo 1000 > /sys/class/leds/led0/delay_on" +if [ ! -d "$STORAGE_MOUNT_POINT" ]; then + mkdir $STORAGE_MOUNT_POINT +fi # Wait for camera DEVICE=$(gphoto2 --auto-detect | grep usb | cut -b 36-42 | sed 's/,/\//') @@ -35,9 +23,6 @@ sudo sh -c "echo 500 > /sys/class/leds/led0/delay_on" # Switch to STORAGE_MOUNT_POINT and create a directory with current date as its name cd $STORAGE_MOUNT_POINT -mkdir "`date --iso-8601`" && cd $_ -# Transfer new files to the USB storage device -#gphoto2 --get-all-files gphoto2 --new # Rename files using ExifTool based on EXIF date and time data exiftool -r -d %Y%m%d-%H%M%S.%%e "-FileName