Created
August 18, 2019 07:15
-
-
Save meeDamian/36831e6d433031363dd2bf8561764a10 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
trap "exit" INT | |
HOSTS=( ln@pi-hdd lnd@pi-other ) | |
echo -e "\nCreating backups for ${#HOSTS[*]} hosts…" | |
DATE=$(date +%F) | |
for host in ${HOSTS[@]}; do | |
net=$(ssh ${host} 'ls .lnd/data/chain/bitcoin/') | |
echo -e "\n=== ${host} (${net}) ===" | |
echo -en " ⚡️ -> 📜 Exporting LND's channel backups…\t" | |
if ! ssh ${host} "lncli -n ${net} exportchanbackup --all | jq '.' > ~/backups/lnd-backups-${net}-${DATE}.json"; then | |
echo "❌" | |
exit 1 | |
fi | |
echo -n "✅ " | |
if ! ssh ${host} "lncli -n ${net} exportchanbackup --all --output_file ~/backups/channels-${net}-${DATE}.backup"; then | |
echo "❌" | |
exit 1 | |
fi | |
echo "✅" | |
mkdir -p "lnd-backups/${host}/" | |
echo -ne " 📜 -> 💻 Downloading backups…\t\t" | |
if ! scp -q ${host}:./backups/\*${DATE}\* "./lnd-backups/${host}/"; then | |
echo "❌" | |
exit 1 | |
fi | |
echo "✅ ✅" | |
done | |
echo -e "\n💻 -> 🗝 Copying backups to Keybase…" | |
for host in ${HOSTS[@]}; do | |
echo -ne " 🗝 ${host} -> RBPs/${host##*-}/\t" | |
if ! rsync --remove-source-files ./lnd-backups/${host}/*${DATE}* "/Volumes/Keybase (mee)/private/meedamian/RBPs/${host##*-}/"; then | |
echo "❌" | |
exit 1 | |
fi | |
echo "✅" | |
done | |
echo -e "\n🎉 All done ⚡️\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment