scripts/backupnaz.sh

41 lines
797 B
Bash
Raw Normal View History

2023-08-10 21:47:21 +02:00
#!/bin/sh
2015-08-02 12:48:17 +02:00
# Monthly backup script for my NAS
2023-08-10 21:47:21 +02:00
#set -e
2015-08-02 12:48:17 +02:00
2023-08-10 21:47:21 +02:00
DEVICE=/dev/sdb1
pass backups/disk | sudo /sbin/cryptsetup luksOpen $DEVICE backups "$@"
if grep /dev/mapper/backups /proc/mounts >/dev/null
2015-08-02 12:48:17 +02:00
then
echo "external drive ($DEVICE) seems to be mounted. good."
else
2023-08-10 21:47:21 +02:00
if sudo mount /dev/mapper/backups /mnt/backups/
2015-08-02 12:48:17 +02:00
then
2023-08-10 21:47:21 +02:00
echo " * external drive ($DEVICE) successfuly mounted."
2015-08-02 12:48:17 +02:00
else
2023-08-10 21:47:21 +02:00
echo " * FATAL: unable to mount"
2015-08-02 12:48:17 +02:00
exit 1
fi
fi
2023-08-10 21:47:21 +02:00
for slot in public private
do
echo
echo " * backing up $slot"
echo
time ionice -c 2 rsync --rsh='ssh -q -o RemoteCommand=none' --info=progress2 -av --delete --exclude-from ~/.backup_excludes naz:/nfs/$slot/ /mnt/backups/$slot/
done
echo
echo " * unmounting"
echo
sleep 2
sync
sudo umount /dev/mapper/backups
sudo dmsetup remove /dev/mapper/backups