Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
best used with github.com/lncm/thebox-compose-system (or probably citadel node which uses the same structure. May also work with umbrel too)
#!/bin/bash
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
# Install the docker-compose box to the current working directory
# Pre-requisites: gpg
# Before running replace "F6287B82CC84BCBD" with your pgp key, and "xxxxxxxxxx.onion" with your node address, and "specterUNIQUEID" with your specter address
# Though you might not have a specter directory
# also replace "/mnt/1tb/node" with your node pathane.
# No error checking for now.
HOST="xxxxxxxxxx.onion"
DATE=`date '+%Y-%m-%d-%H%M%S'`
DIRECTORY="${DATE}-lnnode"
mkdir ${DIRECTORY}
scp -r ${HOST}:/mnt/1tb/node/docker-compose.yml ${DIRECTORY}/
# Make directories
mkdir -p ${DIRECTORY}/secrets
mkdir -p ${DIRECTORY}/lnd
# channel backup
mkdir -p ${DIRECTORY}/lnd/data/chain/bitcoin/mainnet
mkdir -p ${DIRECTORY}/bitcoin
mkdir -p ${DIRECTORY}/invoicer
mkdir -p ${DIRECTORY}/specter
echo "Creating Directory for backup (${DIRECTORY})"
echo "Backing up secrets"
scp -r ${HOST}:/mnt/1tb/node/secrets ${DIRECTORY}
# Bitcoin
echo "Creating and backing up bitcoin config"
scp ${HOST}:/mnt/1tb/node/bitcoin/bitcoin.conf ${DIRECTORY}/bitcoin
# Specter desktop (specter5cf2a50aff36ef81)
echo "Backing up specter desktop files"
scp -r ${HOST}:/mnt/1tb/node/bitcoin/specterUNIQUEID ${DIRECTORY}/bitcoin
scp -r ${HOST}:/mnt/1tb/node/bitcoin/specterUNIQUEID_hotstorage ${DIRECTORY}/bitcoin
echo "Cleaning up bitcoin lock files and logs"
find ${DIRECTORY}/ -type f -name '.walletlock' -exec rm {} +
find ${DIRECTORY}/ -type f -name '*.log' -exec rm {} +
# LND
echo "Backing up LND conf"
scp ${HOST}:/mnt/1tb/node/lnd/lnd.conf ${DIRECTORY}/lnd
echo "Backing up channels"
scp ${HOST}:/mnt/1tb/node/lnd/data/chain/bitcoin/mainnet/channel.backup ${DIRECTORY}/lnd/data/chain/bitcoin/mainnet
# Invoicer
echo "Back up invoicer conf"
scp ${HOST}:/mnt/1tb/node/invoicer/invoicer.conf ${DIRECTORY}/invoicer
# specter
echo "Back up spcter directory"
scp -r ${HOST}:/mnt/1tb/node/specter ${DIRECTORY}
# Terminal
echo "Back up terminal"
scp -r ${HOST}:/mnt/1tb/node/terminal ${DIRECTORY}
# Tor
echo "Backing up Tor"
scp -r ${HOST}:/mnt/1tb/node/tor ${DIRECTORY}
echo "gzip directory and delete it"
tar cvfz ${DIRECTORY}.tgz ${DIRECTORY}
rm -fr ${DIRECTORY}
echo "Encrypt backup with GPG"
cat ${DIRECTORY}.tgz | gpg -r F6287B82CC84BCBD --armor --encrypt > ${DIRECTORY}.asc
echo "Remove backup tgz"
rm ${DIRECTORY}.tgz
echo "gziping asc file"
gzip ${DIRECTORY}.asc
echo "Backup complete"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment