diff --git a/functions/backup.sh b/functions/backup.sh index fc81dce3..f7626653 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -9,7 +9,7 @@ date=$(date '+%Y_%m_%d_%H_%M_%S') [[ "$verbose" == "true" ]] && cli -c 'app kubernetes backup_chart_releases backup_name=''"'HeavyScript_"$date"'"' &> /dev/null && echo_backup+=(HeavyScript_"$date") [[ -z "$verbose" ]] && echo_backup+=("\nNew Backup Name:") && cli -c 'app kubernetes backup_chart_releases backup_name=''"'HeavyScript_"$date"'"' | tail -n 1 &> /dev/null && echo_backup+=(HeavyScript_"$date") mapfile -t list_backups < <(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -Vr -k2,7 | awk -F '|' '{print $2}'| tr -d " \t\r") -if [[ ${#list_backups[@]} -gt "number_of_backups" ]]; then +if [[ ${#list_backups[@]} -gt "$number_of_backups" ]]; then echo_backup+=("\nDeleted the oldest backup(s) for exceeding limit:") overflow=$(( ${#list_backups[@]} - "$number_of_backups" )) mapfile -t list_overflow < <(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -V -k2,7 | awk -F '|' '{print $2}'| tr -d " \t\r" | head -n "$overflow") diff --git a/functions/menu.sh b/functions/menu.sh index e965ed7b..06c138b8 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -34,12 +34,9 @@ case $selection in ;; 4) read -rt 600 -p "Please type the max number of backups to keep: " number_of_backups - number_of_backups=$number_of_backups ! [[ $number_of_backups =~ ^[0-9]+$ ]] && echo -e "Error: -b needs to be assigned an interger\n\"""$number_of_backups""\" is not an interger" >&2 && exit [[ "$number_of_backups" -le 0 ]] && echo "Error: Number of backups is required to be at least 1" && exit echo "Generating backup, please be patient for output.." - menu_backup="true" - backup "$number_of_backups" ;; 5) restore="true"