Hi


I just finished a little backup script.


it will saved lnd directory  (with wallet, config files and channels) in your backup location.

Warning: Becareful, the script need to stop (and start) lnd before backup lnd directory.  

https://gist.github.com/evildido/2b28b2b943775926d20adb0891639a7a


#!/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