update config scripts

This commit is contained in:
rootzoll 2021-05-01 18:27:23 +02:00
parent 7d3b3a19a5
commit ef910efd9b
2 changed files with 36 additions and 24 deletions

View file

@ -26,23 +26,23 @@ isMounted=$(sudo df | grep -c /mnt/hdd)
isBTRFS=$(lsblk -o FSTYPE,MOUNTPOINT | grep /mnt/hdd | awk '$1=$1' | cut -d " " -f 1 | grep -c btrfs) isBTRFS=$(lsblk -o FSTYPE,MOUNTPOINT | grep /mnt/hdd | awk '$1=$1' | cut -d " " -f 1 | grep -c btrfs)
# set place where zipped TAR file gets stored # set place where zipped TAR file gets stored
defaultZipPath="/mnt/hdd/temp/migration" defaultUploadPath="/mnt/hdd/temp/migration"
# get local ip # get local ip
source <(/home/admin/config.scripts/internet.sh status local) source <(/home/admin/config.scripts/internet.sh status local)
# SCP download and upload links # SCP download and upload links
scpDownloadUnix="scp -r 'bitcoin@${localip}:${defaultZipPath}/raspiblitz-*.tar.gz' ./" scpDownloadUnix="scp -r 'bitcoin@${localip}:${defaultUploadPath}/raspiblitz-*.tar.gz' ./"
scpDownloadWin="scp -r bitcoin@${localip}:${defaultZipPath}/raspiblitz-*.tar.gz ." scpDownloadWin="scp -r bitcoin@${localip}:${defaultUploadPath}/raspiblitz-*.tar.gz ."
scpUploadUnix="scp -r ./raspiblitz-*.tar.gz bitcoin@${localip}:${defaultZipPath}" scpUploadUnix="scp -r ./raspiblitz-*.tar.gz bitcoin@${localip}:${defaultUploadPath}"
scpUploadWin="scp -r ./raspiblitz-*.tar.gz bitcoin@${localip}:${defaultZipPath}" scpUploadWin="scp -r ./raspiblitz-*.tar.gz bitcoin@${localip}:${defaultUploadPath}"
# output status data & exit # output status data & exit
if [ "$1" = "status" ]; then if [ "$1" = "status" ]; then
echo "# RASPIBLITZ Data Import & Export" echo "# RASPIBLITZ Data Import & Export"
echo "isBTRFS=${isBTRFS}" echo "isBTRFS=${isBTRFS}"
echo "localip=\"${localip}\"" echo "localip=\"${localip}\""
echo "defaultZipPath=\"${defaultZipPath}\"" echo "defaultUploadPath=\"${defaultUploadPath}\""
echo "scpDownloadUnix=\"${scpDownloadUnix}\"" echo "scpDownloadUnix=\"${scpDownloadUnix}\""
echo "scpUploadUnix=\"${scpUploadUnix}\"" echo "scpUploadUnix=\"${scpUploadUnix}\""
echo "scpDownloadWin=\"${scpDownloadWin}\"" echo "scpDownloadWin=\"${scpDownloadWin}\""
@ -312,23 +312,23 @@ if [ "$1" = "export" ]; then
# zip it # zip it
echo "# Building the Export File (this can take some time) .." echo "# Building the Export File (this can take some time) .."
sudo tar -zcvf ${defaultZipPath}/raspiblitz-export-temp.tar.gz -X ~/.exclude.temp /mnt/hdd 1>~/.include.temp 2>/dev/null sudo tar -zcvf ${defaultUploadPath}/raspiblitz-export-temp.tar.gz -X ~/.exclude.temp /mnt/hdd 1>~/.include.temp 2>/dev/null
# get md5 checksum # get md5 checksum
echo "# Building checksum (can take also a while) ..." echo "# Building checksum (can take also a while) ..."
md5checksum=$(md5sum ${defaultZipPath}/raspiblitz-export-temp.tar.gz | head -n1 | cut -d " " -f1) md5checksum=$(md5sum ${defaultUploadPath}/raspiblitz-export-temp.tar.gz | head -n1 | cut -d " " -f1)
echo "md5checksum=${md5checksum}" echo "md5checksum=${md5checksum}"
# get byte size # get byte size
bytesize=$(wc -c ${defaultZipPath}/raspiblitz-export-temp.tar.gz | cut -d " " -f 1) bytesize=$(wc -c ${defaultUploadPath}/raspiblitz-export-temp.tar.gz | cut -d " " -f 1)
echo "bytesize=${bytesize}" echo "bytesize=${bytesize}"
# final renaming # final renaming
name="raspiblitz${blitzname}${datestamp}-${md5checksum}.tar.gz" name="raspiblitz${blitzname}${datestamp}-${md5checksum}.tar.gz"
echo "exportpath='${defaultZipPath}'" echo "exportpath='${defaultUploadPath}'"
echo "filename='${name}'" echo "filename='${name}'"
sudo mv ${defaultZipPath}/raspiblitz-export-temp.tar.gz ${defaultZipPath}/${name} sudo mv ${defaultUploadPath}/raspiblitz-export-temp.tar.gz ${defaultUploadPath}/${name}
sudo chown bitcoin:bitcoin ${defaultZipPath}/${name} sudo chown bitcoin:bitcoin ${defaultUploadPath}/${name}
# delete temp files # delete temp files
rm ~/.exclude.temp rm ~/.exclude.temp
@ -343,7 +343,7 @@ fi
if [ "$1" = "export-gui" ]; then if [ "$1" = "export-gui" ]; then
# cleaning old migration files from blitz # cleaning old migration files from blitz
sudo rm ${defaultZipPath}/*.tar.gz 2>/dev/null sudo rm ${defaultUploadPath}/*.tar.gz 2>/dev/null
# stopping lnd / bitcoin # stopping lnd / bitcoin
echo "--> stopping services ..." echo "--> stopping services ..."
@ -394,7 +394,7 @@ fi
if [ "$1" = "import" ]; then if [ "$1" = "import" ]; then
# check second parameter for path and/or filename of import # check second parameter for path and/or filename of import
importFile="${defaultZipPath}/raspiblitz-*.tar.gz" importFile="${defaultUploadPath}/raspiblitz-*.tar.gz"
if [ ${#2} -gt 0 ]; then if [ ${#2} -gt 0 ]; then
# check if and/or filename of import # check if and/or filename of import
containsPath=$(echo $2 | grep -c '/') containsPath=$(echo $2 | grep -c '/')
@ -421,7 +421,7 @@ if [ "$1" = "import" ]; then
else else
# is just filename - to use with default path # is just filename - to use with default path
echo "# using file from parameter for import" echo "# using file from parameter for import"
importFile="${defaultZipPath}/${2}" importFile="${defaultUploadPath}/${2}"
fi fi
fi fi
@ -574,8 +574,8 @@ if [ "$1" = "import-gui" ]; then
sudo /home/admin/config.scripts/blitz.datadrive.sh link sudo /home/admin/config.scripts/blitz.datadrive.sh link
# make sure that temp directory exists and can be written by admin # make sure that temp directory exists and can be written by admin
sudo mkdir -p ${defaultZipPath} sudo mkdir -p ${defaultUploadPath}
sudo chmod 777 -R ${defaultZipPath} sudo chmod 777 -R ${defaultUploadPath}
clear clear
echo echo
@ -588,18 +588,18 @@ if [ "$1" = "import-gui" ]; then
echo "ON YOUR LAPTOP open a new terminal and change into" echo "ON YOUR LAPTOP open a new terminal and change into"
echo "the directory where your migration file is and" echo "the directory where your migration file is and"
echo "COPY, PASTE AND EXECUTE THE FOLLOWING COMMAND:" echo "COPY, PASTE AND EXECUTE THE FOLLOWING COMMAND:"
echo "scp -r ./raspiblitz-*.tar.gz admin@${localip}:${defaultZipPath}" echo "scp -r ./raspiblitz-*.tar.gz admin@${localip}:${defaultUploadPath}"
echo "" echo ""
echo "Use password 'raspiblitz' to authenticate file transfer." echo "Use password 'raspiblitz' to authenticate file transfer."
echo "PRESS ENTER when upload is done." echo "PRESS ENTER when upload is done."
read key read key
countZips=$(sudo ls ${defaultZipPath}/raspiblitz-*.tar.gz 2>/dev/null | grep -c 'raspiblitz-') countZips=$(sudo ls ${defaultUploadPath}/raspiblitz-*.tar.gz 2>/dev/null | grep -c 'raspiblitz-')
# in case no upload found # in case no upload found
if [ ${countZips} -eq 0 ]; then if [ ${countZips} -eq 0 ]; then
echo echo
echo "FAIL: Was not able to detect uploaded file in ${defaultZipPath}" echo "FAIL: Was not able to detect uploaded file in ${defaultUploadPath}"
echo "error='no file found'" echo "error='no file found'"
sleep 3 sleep 3
exit 1 exit 1
@ -608,7 +608,7 @@ if [ "$1" = "import-gui" ]; then
# in case of multiple files # in case of multiple files
if [ ${countZips} -gt 1 ]; then if [ ${countZips} -gt 1 ]; then
echo echo
echo "# FAIL: Multiple possible files detected in ${defaultZipPath}" echo "# FAIL: Multiple possible files detected in ${defaultUploadPath}"
echo "error='multiple files'" echo "error='multiple files'"
sleep 3 sleep 3
exit 1 exit 1
@ -616,7 +616,7 @@ if [ "$1" = "import-gui" ]; then
# restore upload # restore upload
echo echo
echo "OK: Upload found in ${defaultZipPath} - restoring data ... (please wait)" echo "OK: Upload found in ${defaultUploadPath} - restoring data ... (please wait)"
source <(sudo /home/admin/config.scripts/blitz.migration.sh "import") source <(sudo /home/admin/config.scripts/blitz.migration.sh "import")
if [ ${#error} -gt 0 ]; then if [ ${#error} -gt 0 ]; then
echo echo

View file

@ -5,6 +5,8 @@ source /mnt/hdd/raspiblitz.conf
# command info # command info
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
echo "# small rescue script to to backup or restore LND data" echo "# small rescue script to to backup or restore LND data"
echo "# -> basic status:"
echo "# lnd.rescue.sh status"
echo "# -> backup all LND data in a tar.gz file for download:" echo "# -> backup all LND data in a tar.gz file for download:"
echo "# lnd.rescue.sh backup [?no-download]" echo "# lnd.rescue.sh backup [?no-download]"
echo "# -> upload a LND data tar.gz file to replace LND data:" echo "# -> upload a LND data tar.gz file to replace LND data:"
@ -16,10 +18,20 @@ if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
exit 1 exit 1
fi fi
localip=$(ip addr | grep 'state UP' -A2 | egrep -v 'docker0|veth' | grep 'eth0\|wlan0\|enp0' | tail -n1 | awk '{print $2}' | cut -f1 -d'/') # get local ip
source <(/home/admin/config.scripts/internet.sh status local)
defaultUploadDir="/home/admin"
mode="$1" mode="$1"
if [ ${mode} = "backup" ]; then
if [ ${mode} = "status" ]; then
echo "localip='${localip}'"
echo "defaultUploadDir='${defaultUploadDir}'"
exit 0
elif [ ${mode} = "backup" ]; then
################################ ################################
# BACKUP # BACKUP