various important fixes and improvements
[distro-setup] / check-subvol-stale
index b977f763f5a85849e7da464c544724e4c908b06c..c6497b5c3f1c0b030c3032ffe5502deab01497d0 100644 (file)
@@ -73,7 +73,7 @@ for d; do
         fi
     fi
 
-    # check if $d is a snapshot of any of the btrbk backups
+    # check if $d is a snapshot of any of the btrbk backups other than the latest
     if [[ ! $stale ]]; then
         for f in ${snaps[@]}; do
             if [[ $f == $last_snap ]]; then continue; fi
@@ -89,7 +89,7 @@ for d; do
     if [[ ! $stale ]]; then
         last_snap_gen=$(btrfs sub show $last_snap| awk '$1 == "Generation:" {print $2}')
         d_gen=$(btrfs sub show $d| awk '$1 == "Generation:" {print $2}')
-        if (( last_snap_gen < d_gen )); then
+        if (( d_gen < last_snap_gen  )); then
             stale=false
         else
             echo "$d stale: it's generation, $d_gen, is earlier than the last snapshot's, $last_snap_gen"