Skip to content

Instantly share code, notes, and snippets.

############### backup script to backup nostream postgres sql database ###############
#!/bin/bash
# set current directory
BASEDIR=$(dirname $0)
# set the backup directory
BACKUP_DIR=$BASEDIR/backup
#backup file name (with date)
BACKUP_FILE=nostream-$(date +%Y-%m-%d).sql
#!/bin/bash
#alias lightning-cli="docker exec -it cln lightning-cli"
#docker exec -it cln lightning-cli getinfo
#working_path=/home/bitcoin/script-earning
BASEDIR=$(dirname $0)
working_path=${BASEDIR}
_now=$(date +"%d:%m:%Y")
JSON=`docker exec cln lightning-cli clboss-status | jq .offchain_earnings_tracker`
echo $JSON | jq -r 'map({in_earnings, in_expenditures}) | (first | keys_unsorted) as $keys | map([to_entries[] | .value]) as $rows | $keys,$rows[] | @csv' > $working_path/status.csv
awk -F"," '{x+=$1}END{print "Total earning: " x/1000}' $working_path/status.csv
#!/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