Skip to content

Instantly share code, notes, and snippets.

@evildido evildido/backupLND.sh
Last active Aug 18, 2019

Embed
What would you like to do?
#!/bin/bash
# lnd location (usually $HOME/.lnd on linux)
LND_DIR=""
# You backup directory
BACKUP_DIR=""
# Password used to unlock lnd wallet (base64 format)
# On unix system, run this command to convert your password to base64 > printf '%s' "MyPassword" | base64
LND_PASS_WALLET=""
# Don't modify this one
MACAROON_HEADER="Grpc-Metadata-macaroon: $(xxd -ps -u -c 1000 ${LND_DIR}/data/chain/bitcoin/mainnet/admin.macaroon)"
lncli --lnddir=$LND_DIR stop
# wait until lnd stop
while pgrep -x lnd > /dev/null; do
echo "LND has not yet stopped. Waiting 3 more seconds"
sleep 3
done
rsync --progress -aAXz -v $LND_DIR $BACKUP_DIR
echo "Backup done"
echo "start lnd"
screen -S lnd1 -d -m bash -c "lnd --lnddir=$LND_DIR"
sleep 2
screen -ls
echo "lnd started... unlock wallet"
sleep 1
echo $MACAROON_HEADER
curl --cacert $LND_DIR/tls.cert --header "$MACAROON_HEADER" https://localhost:8080/v1/unlockwallet -d '{ "wallet_password":'\"$LND_PASS_WALLET\"' }' -v
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.