Corin's backup scripts

This commit is contained in:
2025-03-10 19:28:44 +10:30
parent 41d987cae6
commit 78286622a8
4 changed files with 76 additions and 0 deletions

26
bash/copy_keyfile Normal file
View File

@@ -0,0 +1,26 @@
#!/bin/bash
#/usr/local/bin/copy_keyfile
# Copy over the encryption key and mount the external drive
# Try to copy over the encryption key. Give up after three minutes.
for attempt in $(seq 1 6); do
# Attempt to copy the file
if scp unraid@192.168.10.204:keyfile /dev/shm/keyfile; then
# Exit the loop on success
break
else
# Wait before retrying
sleep 30
fi
done
# Check if the loop completed successfully
if [ $? -ne 0 ]; then
echo "Failed to copy the encryption key after multiple attempts." >&2
exit 1 # Exit with failure code 1
fi
# Mount the drive
cryptsetup --key-file /dev/shm/keyfile luksOpen /dev/sdb1 corin
mount /dev/mapper/corin /media/corin