Skip to content

Commit

Permalink
Minor fixes in the restoring of a backup
Browse files Browse the repository at this point in the history
  • Loading branch information
radio24 committed Oct 6, 2024
1 parent 328fbcd commit 27bb69c
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 34 deletions.
3 changes: 1 addition & 2 deletions bin/backup
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ CLIENT_ONION_AUTH_DIR="${DATA_DIR}/onion_auth"
HASHED_FINGERPRINT_DIR="${DATA_DIR}/hashed-fingerprint"
WEBSITE_DIR="/var/www"
NGINX_DIR="/etc/nginx"
# NEW post-v.0.5.3: Backup the entire directory to preserve also the exlusion files --> SUPPORT NOT YET ADDED TO RESTORE!!!
RUNDIR="/home/torbox/torbox/run"
TXT_DIR="/home/torbox/torbox/text"

Expand All @@ -63,7 +62,7 @@ INPUT=$(cat "${TXT_DIR}/backup-text")
if (whiptail --title "TorBox - INFO (scroll down!)" --scrolltext --yesno "$INPUT" $MENU_HEIGHT_25 $MENU_WIDTH); then
exitstatus=$?
if [ "$exitstatus" = "0" ]; then

# OBFS4 Bridge Relay data exist?
if sudo -u "${TOR_USER}" [ ! -f "${HASHED_FINGERPRINT_DIR}" ]; then
OBFS4RELAY=0
Expand Down
60 changes: 30 additions & 30 deletions bin/restore
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ TXT_DIR="$TORBOX_PATH/text"
CLEARNET_LIST="clearnet-list"
CLEARNET_LIST_FILE="$TORBOX_PATH/run/$CLEARNET_LIST"
# Format of CLEARNET_LIST_FILE_OWN: <DOMAINNAME> <IP1> [<IPn>]
CLEARNET_LIST_FILE_OWN="$TORBOX_PATH/run/clearnet-list.own"
CLEARNET_LIST_FILE_OWN="$TORBOX_PATH/run/$CLEARNET_LIST.own"
VPN_LIST="vpn-list"
VPN_LIST_FILE="$TORBOX_PATH/run/$VPN_LIST"
# Format of CLEARNET_LIST_FILE_OWN: <DOMAINNAME> <IP1> [<IPn>]
VPN_LIST_FILE_OWN="$TORBOX_PATH/run/vpn-list.own"
VPN_LIST_FILE_OWN="$TORBOX_PATH/run/$VPN_LIST.own"
OLD_EXCLUSIONLISTS=0
RESTORE_EXCLUSIONLISTS=0

Expand Down Expand Up @@ -466,7 +466,7 @@ if (whiptail --title "TorBox - INFO (scroll down!)" --scrolltext --yesno "$INPUT
fi
fi

# Restore the activity of the Web SSH
# Restore the activity of the webssh
echo -e "${RED}[+] Configuring webssh, if TWEBSSH=1...${NOCOLOR}"
if grep "TWEBSSH=1" ${RUNFILE} ; then
[ ! -f /etc/nginx/sites-available/webssh.conf ] && sudo cp $TORBOX_PATH/etc/nginx/sites-available/sample-webssh.conf /etc/nginx/sites-available/webssh.conf
Expand All @@ -485,14 +485,14 @@ if (whiptail --title "TorBox - INFO (scroll down!)" --scrolltext --yesno "$INPUT
sudo systemctl restart nginx

# Should we activate domain exclusion lists?
if [ -f "$CLEARNET_LIST_FILE_OWN" ] || [ -f "$VPN_LIST_FILE_OWN" ]; then OLD_EXCLUSIONLISTS=1; fi
if [ -f "restore$CLEARNET_LIST_FILE_OWN" ] || [ -f "restore$VPN_LIST_FILE_OWN" ]; then RESTORE_EXCLUSIONLISTS=1; fi
if grep "UNPROTECTED_DOMAIN=1" ${RUNFILE} || grep "UNPROTECTED_DOMAIN=1" "restore${RUNFILE}"; then
if (whiptail --title "TorBox - RESTORE" --yesno "On the target system and/or on the backed up system, the lists which contain domains to be excluded from tor-routing were/are active.\n\nDo you want to activate these exclusion lists on the restored system?" $MENU_HEIGHT_10 $MENU_WIDTH); then
if (whiptail --title "TorBox - RESTORE" --yesno "On the target system and/or on the backed up system, the lists which contain domains to be excluded from tor-routing were/are active.\n\nDo you want to activate domain exclusion on the restored system (NO will delete active lists and deactivate domain exclusion)?" $MENU_HEIGHT_10 $MENU_WIDTH); then
exitstatus=$?
clear
# exitstatus == 255 means that the ESC key was pressed
[ "$exitstatus" == "255" ] && exit 0
if [ -f "$CLEARNET_LIST_FILE_OWN" ] || [ -f "$VPN_LIST_FILE_OWN" ]; then OLD_EXCLUSIONLISTS=1; fi
if [ -f "restore$CLEARNET_LIST_FILE_OWN" ] || [ -f "restore$VPN_LIST_FILE_OWN" ]; then RESTORE_EXCLUSIONLISTS=1; fi
if [ "$OLD_EXCLUSIONLISTS" == "1" ] && [ "$RESTORE_EXCLUSIONLISTS" == "1" ]; then
if (whiptail --title "TorBox - RESTORE" --yesno --no-button "KEEP" --yes-button "RESTORE" "Do you want to KEEP the current exclusion lists or RESTORE the ones in the backup?" $MENU_HEIGHT_10 $MENU_WIDTH); then
exitstatus=$?
Expand Down Expand Up @@ -539,32 +539,32 @@ if (whiptail --title "TorBox - INFO (scroll down!)" --scrolltext --yesno "$INPUT
sudo ipset destroy 2>/dev/null
fi
else
if (whiptail --title "TorBox - RESTORE" --yesno "On the target system and/or on the backed up system, lists which contain domains to be excluded from tor-routing were/are present, but not active.\n\nDo you want to keep these exclusion lists on the restored system (we will not activate them)?" $MENU_HEIGHT_10 $MENU_WIDTH); then
exitstatus=$?
clear
# exitstatus == 255 means that the ESC key was pressed
[ "$exitstatus" == "255" ] && exit 0
if [ -f "$CLEARNET_LIST_FILE_OWN" ] || [ -f "$VPN_LIST_FILE_OWN" ]; then OLD_EXCLUSIONLISTS=1; fi
if [ -f "restore$CLEARNET_LIST_FILE_OWN" ] || [ -f "restore$VPN_LIST_FILE_OWN" ]; then RESTORE_EXCLUSIONLISTS=1; fi
if [ "$OLD_EXCLUSIONLISTS" == "1" ] && [ "$RESTORE_EXCLUSIONLISTS" == "1" ]; then
if (whiptail --title "TorBox - RESTORE" --yesno --no-button "KEEP" --yes-button "RESTORE" "Do you want to KEEP the current exclusion lists or RESTORE the ones in the backup?" $MENU_HEIGHT_10 $MENU_WIDTH_REDUX); then
exitstatus=$?
clear
# exitstatus == 255 means that the ESC key was pressed
[ "$exitstatus" == "255" ] && exit 0
cp "restore$CLEARNET_LIST_FILE_OWN" $RUNFILE
cp "restore$VPN_LIST_FILE_OWN" $RUNFILE
elif [ "$OLD_EXCLUSIONLISTS" == "0" ] && [ "$RESTORE_EXCLUSIONLISTS" == "1" ]; then
cp "restore$CLEARNET_LIST_FILE_OWN" $RUNFILE
if [ "$OLD_EXCLUSIONLISTS" == "1" ] || [ "$RESTORE_EXCLUSIONLISTS" == "1" ]; then
if (whiptail --title "TorBox - RESTORE" --yesno "On the target system and/or on the backed up system, domain exclusion lists are present, but not active.\n\nDo you want to keep these exclusion lists on the restored system (we will not activate them)?" $MENU_HEIGHT_10 $MENU_WIDTH); then
exitstatus=$?
clear
# exitstatus == 255 means that the ESC key was pressed
[ "$exitstatus" == "255" ] && exit 0
if [ "$OLD_EXCLUSIONLISTS" == "1" ] && [ "$RESTORE_EXCLUSIONLISTS" == "1" ]; then
if (whiptail --title "TorBox - RESTORE" --yesno --no-button "KEEP" --yes-button "RESTORE" "Do you want to KEEP the current exclusion lists or RESTORE the ones in the backup?" $MENU_HEIGHT_10 $MENU_WIDTH_REDUX); then
exitstatus=$?
clear
# exitstatus == 255 means that the ESC key was pressed
[ "$exitstatus" == "255" ] && exit 0
cp "restore$CLEARNET_LIST_FILE_OWN" $RUNFILE
cp "restore$VPN_LIST_FILE_OWN" $RUNFILE
fi
elif [ "$OLD_EXCLUSIONLISTS" == "0" ] && [ "$RESTORE_EXCLUSIONLISTS" == "1" ]; then
cp "restore$CLEARNET_LIST_FILE_OWN" $RUNFILE
cp "restore$VPN_LIST_FILE_OWN" $RUNFILE
fi
fi
else
[ -f "$CLEARNET_LIST_FILE_OWN" ] && rm "$CLEARNET_LIST_FILE_OWN"
[ -f "$VPN_LIST_FILE_OWN" ] && rm "$VPN_LIST_FILE_OWN"
[ -f "restore$CLEARNET_LIST_FILE_OWN" ] && rm "restore$CLEARNET_LIST_FILE_OWN"
[ -f "restore$VPN_LIST_FILE_OWN" ] && rm "restore$VPN_LIST_FILE_OWN"
fi
else
if [ -f "$CLEARNET_LIST_FILE_OWN" ]; then sudo rm $CLEARNET_LIST_FILE_OWN; fi
if [ -f "$CLEARNET_LIST_FILE" ]; then sudo rm $CLEARNET_LIST_FILE; fi
if [ -f "$VPN_LIST_FILE_OWN" ]; then sudo rm $VPN_LIST_FILE_OWN; fi
if [ -f "$VPN_LIST_FILE" ]; then sudo rm $VPN_LIST_FILE; fi
fi
fi
fi

# We don't need the restore directory anymore
Expand Down
2 changes: 1 addition & 1 deletion menu-update
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ CHOICE=$(whiptail --nocancel --title "TorBox v.0.5.3 - UPDATE & MAINTENANCE MENU
"10" "Reset tor and force a change of the permanent entry node" \
"11" "Remove all tor bridges and use built-in bridges" \
"12" "Renew the list of excluded slow tor relays" \
"13" "Restart Nginx, webssh and TFS" \
"13" "Restart Nginx, webssh, TFS and TCS" \
"14" "Rerun the \"First Start-up\" script" \
"15" "Erase all log files" \
"16" "Time synchronization" \
Expand Down
2 changes: 1 addition & 1 deletion text/restore-text
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
This menu entry restores TorBox's configuration, which was saved with TorBox's backup script. If available, it includes the settings for the OBFS4 Bridge Relay or Onion Services.
This menu entry restores TorBox's configuration, which was saved with TorBox's backup script. If available, it includes the settings for the domain exclusion, OBFS4 Bridge Relay and Onion Services.

Please upload the backup file using a SFTP client (the same login and password as your SSH client) in TorBox's home directory. Alternatively, you can transfer the backup file by connecting an USB stick to your TorBox. You can probably mount the USB stick by "sudo mount /dev/sda /mnt" and then copy the backup file from the stick to TorBox's home directory.

Expand Down

0 comments on commit 27bb69c

Please sign in to comment.