From 26815e9783dbc9e16257cc6ad24d13f27813c2af Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 23:22:06 -0600 Subject: [PATCH] test loop --- functions/backup.sh | 113 +++++++++++++++++++++++++------------------- 1 file changed, 65 insertions(+), 48 deletions(-) diff --git a/functions/backup.sh b/functions/backup.sh index c28a2e7b..b8946e4a 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -30,57 +30,74 @@ export -f backup deleteBackup(){ -clear -x && echo "pulling all restore points.." -list_backups=$(cli -c 'app kubernetes list_backups' | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl | column -t) -clear -x -if [[ -z "$list_backups" ]]; then - echo "No restore points available" - exit -else - title - echo -e "Choose a restore point to delete\nThese may be out of order if they are not HeavyScript backups" -fi -echo "$list_backups" -read -rt 120 -p "Please type a number: " selection -restore_point=$(echo "$list_backups" | grep ^"$selection " | awk '{print $2}') -#Check for valid selection. If none, kill script -if [[ -z "$selection" ]]; then - echo "Your selection cannot be empty" - exit -elif [[ -z "$restore_point" ]]; then - echo "Invalid Selection: $selection, was not an option" - exit -fi while true do - echo -e "\nWARNING:\nYou CANNOT go back after deleting your restore point" - echo -e "\n\nYou have chosen:\n$restore_point\n\nWould you like to continue?" - echo -e "Yes\n0 exit" - read -rt 120 -p "Type \"yes\" to continue, or exit with \"0\": " yesno - case $yesno in - [Yy][Ee][Ss]) - echo -e "\nDeleting $restore_point" - cli -c 'app kubernetes delete_backup backup_name=''"'"$restore_point"'"' &>/dev/null || { echo "Failed to delete backup.."; exit; } - echo "Sucessfully deleted" - break - ;; - 0|[Ee][Xx][Ii][Tt]) - echo "Exiting" - exit - ;; - *) - echo "Invalid Selection" - ;; - esac + clear -x && echo "pulling all restore points.." + list_backups=$(cli -c 'app kubernetes list_backups' | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl | column -t) + clear -x + if [[ -z "$list_backups" ]]; then + echo "No restore points available" + exit + else + title + echo -e "Choose a restore point to delete\nThese may be out of order if they are not HeavyScript backups" + fi + echo "$list_backups" + read -rt 120 -p "Please type a number: " selection + restore_point=$(echo "$list_backups" | grep ^"$selection " | awk '{print $2}') + #Check for valid selection. If none, kill script + if [[ -z "$selection" ]]; then + echo "Your selection cannot be empty" + continue + elif [[ -z "$restore_point" ]]; then + echo "Invalid Selection: $selection, was not an option" + continue + fi + while true + do + echo -e "\nWARNING:\nYou CANNOT go back after deleting your restore point" + echo -e "\n\nYou have chosen:\n$restore_point\n\nWould you like to continue?" + echo -e "Yes\n0 exit\n" + read -rt 120 -p "Type \"yes\" to continue, or exit with \"0\": " yesno + case $yesno in + [Yy][Ee][Ss]) + echo -e "\nDeleting $restore_point" + cli -c 'app kubernetes delete_backup backup_name=''"'"$restore_point"'"' &>/dev/null || { echo "Failed to delete backup.."; exit; } + echo "Sucessfully deleted" + break + ;; + 0|[Ee][Xx][Ii][Tt]) + echo "Exiting" + exit + ;; + *) + echo "Invalid Selection" + ;; + esac + done + while true + do + echo "Delete more?" + echo "1 Yes" + echo "2 No" + read -rt 120 -p "Please type a number: " yesno + case $yesno in + 1) + break + ;; + 2) + exit + ;; + *) + echo "$yesno was not an option, try again" + sleep 2 + continue + ;; + + esac + + done done -# while true -# do -# echo "Delete more?" -# echo - - -# done - } export -f deleteBackup