From 27eec996aaeb98fc07017c23baeafb39a548876d Mon Sep 17 00:00:00 2001 From: heavybullets8 Date: Sat, 17 Dec 2022 20:27:53 -0700 Subject: [PATCH] Edit restore message on scale ver change --- functions/backup.sh | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/functions/backup.sh b/functions/backup.sh index 43b44b70..3d795cd2 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -149,9 +149,13 @@ do done +# Boot Query +boot_query=$(cli -m csv -c 'system bootenv query created,realname') + + # Get the date of system version and when it was updated current_version=$(cli -m csv -c 'system version' | awk -F '-' '{print $3}') -when_updated=$(cli -m csv -c 'system bootenv query created,realname' | grep "$current_version",\ +when_updated=$(echo "$boot_query" | grep "$current_version",\ | awk -F ',' '{print $2}' | sed 's/[T|-]/_/g' | sed 's/:/_/g' | awk -F '_' '{print $1 $2 $3 $4 $5}') @@ -159,12 +163,25 @@ when_updated=$(cli -m csv -c 'system bootenv query created,realname' | grep "$cu restore_point_date=$(echo "$restore_point" | awk -F '_' '{print $2 $3 $4 $5 $6}' | tr -d "_") +# Grab previous version +previous_version=$(echo "$boot_query" | sort -nr | grep -A 1 "$current_version," | tail -n 1) + + # Compare the dates while (("$restore_point_date" < "$when_updated" )) do clear -x echo "The restore point you have chosen is from an older version of Truenas Scale" echo "This is not recommended, as it may cause issues with the system" + echo + echo "Current SCALE Information:" + echo "Version: $current_version" + echo "When Updated: $(echo "$restore_point" | awk -F '_' '{print $2 "-" $3 "-" $4}')" + echo + echo "Restore Point SCALE Information:" + echo "Version: $(echo "$previous_version" | awk -F ',' '{print $1}')" + echo "When Updated: $(echo "$previous_version" | awk -F ',' '{print $2}' | awk -F 'T' '{print $1}')" + echo if read -rt 120 -p "Would you like to proceed? (y/N): " yesno || { echo -e "\nFailed to make a selection in time" ; exit; }; then case $yesno in [Yy] | [Yy][Ee][Ss])