Use internal storage for backup
This commit is contained in:
@@ -1,26 +1,14 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# Specify a storage device and its mount point
|
# Specify a storage device and its mount point
|
||||||
STORAGE_DEV="sda1"
|
STORAGE_MOUNT_POINT="/home/pi/BACKUP"
|
||||||
STORAGE_MOUNT_POINT="/media/storage"
|
|
||||||
|
|
||||||
# Set the ACT LED to heartbeat
|
# Set the ACT LED to heartbeat
|
||||||
sudo sh -c "echo heartbeat > /sys/class/leds/led0/trigger"
|
sudo sh -c "echo heartbeat > /sys/class/leds/led0/trigger"
|
||||||
|
|
||||||
# Wait for a USB storage device (e.g., a USB flash drive)
|
if [ ! -d "$STORAGE_MOUNT_POINT" ]; then
|
||||||
STORAGE=$(ls /dev/* | grep $STORAGE_DEV | cut -d"/" -f3)
|
mkdir $STORAGE_MOUNT_POINT
|
||||||
while [ -z ${STORAGE} ]
|
fi
|
||||||
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"
|
|
||||||
|
|
||||||
# Wait for camera
|
# Wait for camera
|
||||||
DEVICE=$(gphoto2 --auto-detect | grep usb | cut -b 36-42 | sed 's/,/\//')
|
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
|
# Switch to STORAGE_MOUNT_POINT and create a directory with current date as its name
|
||||||
cd $STORAGE_MOUNT_POINT
|
cd $STORAGE_MOUNT_POINT
|
||||||
mkdir "`date --iso-8601`" && cd $_
|
|
||||||
# Transfer new files to the USB storage device
|
|
||||||
#gphoto2 --get-all-files
|
|
||||||
gphoto2 --new
|
gphoto2 --new
|
||||||
# Rename files using ExifTool based on EXIF date and time data
|
# Rename files using ExifTool based on EXIF date and time data
|
||||||
exiftool -r -d %Y%m%d-%H%M%S.%%e "-FileName<DateTimeOriginal" .
|
exiftool -r -d %Y%m%d-%H%M%S.%%e "-FileName<DateTimeOriginal" .
|
||||||
|
|||||||
Reference in New Issue
Block a user