Due to the main previous archiving script falling over itself I have started to write a new version with the help of #bash on freenode.
Conceptual things I have changed:
- Using a whitelist of UUIDs instead of mountpoints to determine if a drive is plugged in.
- Keyfiles instead of password so an expect script is not required.
- Tar instead of rsync, even with limitations rsync was playing havoc with asterisk
This version uses gnupg instead of truecrypt, but I have plans on seeing if truecrypt can mount without requiring any sort of expect script. Also the script doesn’t have incremental archiving implemented, but tar does support incremental archiving.
In short expect a different version to emerge soon.
#!/bin/bash #UUID used for drives (seperate drives using " " ) drives="9a3ffd9e-ee84-4475-ab0f-60b98910eeef dd519d4f-a63b-4579-bcc7-0feb073ba030" mntloc="/mnt/bkdrive" #check if drive is active: fuser ... #step one umount folder echo "attempting to unmount $mntloc" umount "$mntloc" #finds first acceptable uuid found="0" for i in $drives; do #sets the dev location devloc="$(blkid -U $i)" #checks drive is found if [ -n "$devloc" ]; then echo "suitable drive found. (UUID=$i $devloc) ..now mounting.." found="1" break; fi done #if drive not found. exit if [[ ${found} -eq "0" ]]; then echo "Warning no suitable drive found!" exit 1 fi #check mounting worked. if (mount -t auto "$devloc" "$mntloc"); then echo "mounted."; else echo "Failed to mount. Exiting." exit 1; fi #backup /ANAT/Common in a screen file="$mntloc/ANATCommon_bk_$(date +%Y-%m-%d).tar.xz" #screen -S Backup -d -m tar -cvJ /ANAT/Common | gpg -r [email protected] -e -o "${file}.gpg"