minor improvements
[distro-setup] / btrbk-run
index dcca4b7dd036dca6fb662f40e9904a824160e6bd..755e5cc25cc329e38ffb02e752bbce5706610f8c 100644 (file)
--- a/btrbk-run
+++ b/btrbk-run
@@ -269,7 +269,9 @@ if [[ ! -v targets && ! $source ]]; then
             targets+=(x3wg.b8.nz)
           fi
         fi
-        for h in frodo kd; do
+        # temporarily disabled while doing recovery
+#        for h in frodo kd; do
+        for h in kd; do
           if [[ $HOSTNAME == "$h" ]]; then
             continue
           fi
@@ -366,6 +368,7 @@ echo "mountpoints: ${mountpoints[*]}"
 
 ##### end command line parsing ########
 
+# todo: this has a timing problem, since btrbk.timer could activate the service after this check.
 if ! $fast && [[ $source ]]; then
   if [[ $(ssh $source ps --no-headers -o comm 1) == systemd ]]; then
     status=$(ssh $source systemctl is-active btrbk.service) || : # normally returns 3
@@ -441,16 +444,21 @@ else
       root_size=$(( 1024 * 1024 * 2000 )) #2tb
       percent_used=10
       zone=$(date +%z)
-    elif tmpstr=$(timeout -s 9 6 ssh root@$h "mkdir -p /mnt/root/btrbk /mnt/o/btrbk && date +%z && df --output=size,pcent / | tail -n1"); then
-      IFS=" " read -r -a remote_info <<<"$tmpstr"
-
-      zone=${remote_info[0]}
-      root_size=${remote_info[1]}
-      percent_used=${remote_info[2]%%%}
-
-      if (( ${#remote_info[@]} != 3 )); then
-        die "error: didnt get 3 fields in test ssh to target $h. investigate"
+    elif remote_str=$(timeout -s 9 6 ssh root@$h "mkdir -p /mnt/root/btrbk /mnt/o/btrbk && date +%z && df --output=size,pcent / | tail -n1"); then
+      mapfile -t tmp_array <<<"$remote_str"
+      zone="${tmp_array[0]}"
+      IFS=" " read -r root_size percent_used <<<"${tmp_array[1]}"
+      percent_used=${percent_used%%%}
+
+      if (( ${#tmp_array[@]} != 2 )); then
+        die "error: didnt get 2 lines in test ssh to target $h. investigate"
       fi
+      case $percent_used in
+        [0-9]|[1-9][0-9]) : ;;
+        *)
+          die "error: didnt get percent disk use in test ssh to target $h. investigate"
+          ;;
+      esac
     else
       sshfail+=($h)
       continue
@@ -654,7 +662,9 @@ done
 if [[ $source ]]; then
   m mount-latest-subvol "${subvols[@]}"
 else
-  m /a/exe/mount-latest-remote ${targets[@]}
+  for tg in ${targets[@]}; do
+    m /a/exe/mount-latest-remote "$tg" "${subvols[@]}" || ret=$?
+  done
 fi
 
 if [[ $ret == 0 ]]; then