lndbackup also using backup device if connected (#4053)

* copy backup file to backupdevice (#3979)
* #3979 adding free space check to backup device
* just 50MB for safety is enough
This commit is contained in:
/rootzoll 2023-08-13 15:20:02 +02:00 committed by GitHub
parent ef47911beb
commit 684322e1e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -169,6 +169,25 @@ if [ ${mode} = "lnd-export" ]; then
exit 1
fi
# if a backup device is connected (and has enogh free space) copy it there
source <(/home/admin/config.scripts/blitz.backupdevice.sh status)
if [ $isMounted == 1 ]; then
# get free space in bytes from backup device
freeSpace=$(df | grep -m1 "/mnt/backup" | awk '{print $4}')
# subtract 50MB for safety
freeSpace=$(expr ${freeSpace} - 50000000)
# check if enough space on backup device
if [ ${freeSpace} -gt ${byteSize} ]; then
echo "# making copy to backup device ..."
sudo cp ${downloadPath}/lnd-rescue-${md5checksum}.tar.gz /mnt/backup/lnd-rescue-${md5checksum}.tar.gz
else
echo "# not enough space on backup device for extra copy'"
fi
fi
# output result data
echo "# lnd service is stopped for security"
echo "filename='${downloadPath}/lnd-rescue-${md5checksum}.tar.gz'"