Corin's backup scripts
This commit is contained in:
10
bash/backup-status
Normal file
10
bash/backup-status
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# /usr/local/bin/
|
||||||
|
# backup-status by htrigg
|
||||||
|
#
|
||||||
|
# Displays the mounted media disks and the backup directories
|
||||||
|
|
||||||
|
tput setaf 2;df -h | awk '$6 ~ "media"'
|
||||||
|
tput sgr0;ls -ltr --color=auto /media/corin/BACKUP
|
||||||
|
|
||||||
26
bash/copy_keyfile
Normal file
26
bash/copy_keyfile
Normal 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
|
||||||
|
|
||||||
20
bash/remount-all
Normal file
20
bash/remount-all
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# /usr/local/bin/
|
||||||
|
# remount-all by htrigg
|
||||||
|
#
|
||||||
|
# mount and decrypt all drives after a power outage
|
||||||
|
#
|
||||||
|
# v1.0 released 05/01/2020
|
||||||
|
# v2.0 released 02/06/2022
|
||||||
|
# v3.0 released 10/03/2025 - moved to sdb1
|
||||||
|
|
||||||
|
echo "Mounting Coriakin..."
|
||||||
|
mount /media/coriakin
|
||||||
|
echo "Opening the crypt..."
|
||||||
|
cryptsetup luksOpen /dev/sdb1 corin
|
||||||
|
echo "Mounting Corin..."
|
||||||
|
mount /dev/mapper/corin /media/corin
|
||||||
|
df -h | awk '$6 ~ "media"'
|
||||||
|
ls -latr /media/corin/BACKUP
|
||||||
|
|
||||||
20
bash/remove-corin
Normal file
20
bash/remove-corin
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# /usr/local/bin/
|
||||||
|
# remove-corin by htrigg
|
||||||
|
#
|
||||||
|
# unmount and secure data
|
||||||
|
# run using 'sudo remove-corin'
|
||||||
|
#
|
||||||
|
# v1.0 released 0/01/2020
|
||||||
|
|
||||||
|
if [[ $UID != 0 ]]; then
|
||||||
|
echo "Please run this script with sudo:"
|
||||||
|
echo "sudo $0 $*"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "Unmounting Corin..."
|
||||||
|
umount /media/corin
|
||||||
|
echo "Closing the crypt..."
|
||||||
|
cryptsetup luksClose corin
|
||||||
|
|
||||||
Reference in New Issue
Block a user