Improve card ID handling 🐒
This commit is contained in:
15
backup.sh
15
backup.sh
@@ -52,19 +52,18 @@ if [ ! -z $CARD_READER ]; then
|
||||
mount /dev/$CARD_DEV $CARD_MOUNT_POINT
|
||||
# # Set the ACT LED to blink at 500ms to indicate that the card has been mounted
|
||||
sudo sh -c "echo 500 > /sys/class/leds/led0/delay_on"
|
||||
# Create the CARD_ID file containing a random 8-digit identifier if doesn't exist
|
||||
if [ ! -f $CARD_MOUNT_POINT/CARD_ID ]; then
|
||||
< /dev/urandom tr -cd 0-9 | head -c 8 > $CARD_MOUNT_POINT/CARD_ID
|
||||
# Create a .id random identifier file if doesn't exist
|
||||
if [ ! -f $CARD_MOUNT_POINT/*.id ]; then
|
||||
ID=$RANDOM
|
||||
touch $ID."id"
|
||||
fi
|
||||
|
||||
# Set the backup path
|
||||
BACKUP_PATH=$STORAGE_MOUNT_POINT/"$ID"
|
||||
|
||||
# Log the output of the lsblk command for troubleshooting
|
||||
sudo lsblk > lsblk.log
|
||||
|
||||
# Read the 8-digit identifier number from the CARD_ID file on the card
|
||||
# and use it as a directory name in the backup path
|
||||
read -r ID < $CARD_MOUNT_POINT/CARD_ID
|
||||
BACKUP_PATH=$STORAGE_MOUNT_POINT/"$ID"
|
||||
|
||||
# Perform backup using rsync
|
||||
rsync -avh $CARD_MOUNT_POINT/ $BACKUP_PATH
|
||||
# Turn off the ACT LED to indicate that the backup is completed
|
||||
|
||||
Reference in New Issue
Block a user