mynode/rootfs/standard/usr/bin/mynode_lnd_channel_backup.sh

30 lines
689 B
Bash
Raw Normal View History

2019-06-15 23:02:44 +00:00
#!/bin/bash
source /usr/share/mynode/mynode_config.sh
mkdir -p $LND_BACKUP_FOLDER
echo "Waiting on lnd channel backup..."
while [ ! -f $LND_CHANNEL_FILE ]; do
sleep 1m
done
echo "Channel backup found!"
2021-03-07 04:52:44 +00:00
# Always copy once to make first backup
cp -f $LND_CHANNEL_FILE $LND_CHANNEL_FILE_BACKUP
2019-06-15 23:02:44 +00:00
while true; do
# If file has been deleted, exit so we cat restart
if [ ! -f $LND_CHANNEL_FILE ]; then
echo "Channel file deleted... exiting."
exit 1
fi
# Wait for changes
inotifywait -e modify -e create -e delete $LND_CHANNEL_FILE
cp -f $LND_CHANNEL_FILE $LND_CHANNEL_FILE_BACKUP
echo "Backed up LND channels!"
done
# Should never exit
exit 99