fix btrbk service
[distro-setup] / mount-latest-subvol
index aa35efa5720bbb9573b44939719a7baec8dd74a2..ea1d1f89195cc26420e68aa462671d1288eef5c4 100644 (file)
@@ -299,6 +299,7 @@ for vol in q a o i; do
     fi
   done
 
+  # if we unmounted some but not all, restore them and move on
   if ! $umount_ret; then
     for dir in ${unmounted[@]}; do
       mnt $dir
@@ -306,6 +307,7 @@ for vol in q a o i; do
     continue
   fi
 
+  #### begin dealing with leaf vols ####
   # todo: decipher /mnt/root, like we do in check-subvol-stale
   cd /mnt/root
   if [[ -e $vol ]]; then
@@ -315,6 +317,8 @@ for vol in q a o i; do
 
     ### begin check if leaf is different, delete it if not ###
     if [[ -e /a/opt/btrfs-snapshots-diff/btrfs-snapshots-diff.py ]]; then
+      source /a/bin/distro-functions/src/package-manager-abstractions
+      pi python-jmespath # dependency
       parentid=$(btrfs sub show $leaf | awk '$1 == "Parent" && $2 == "UUID:" {print $3}')
       bsubs=(/mnt/root/btrbk/$vol.*)
       bsub=
@@ -328,7 +332,7 @@ for vol in q a o i; do
       if [[ $bsub ]]; then
         tmp=$(mktemp)
         # in testing, same subvol is 136 bytes. allow some overhead
-        btrfs send --no-data -p $bsub $leaf | head -c 1000 > $tmp
+        btrfs send --no-data -p $bsub $leaf | head -c 1000 > $tmp || [[ $? == 141 ]]
         if (( $(stat -c%s $tmp) < 1000)); then
           # example output for an empty diff:
           # Found a valid Btrfs stream header, version 1
@@ -356,6 +360,8 @@ for vol in q a o i; do
     done
     ## end expire leaf vols ##
   fi
+  #### end dealing with leaf vols ####
+
   # Note, we make a few assumptions in this script, like
   # $d was not a different subvol id than $vol, and
   # things otherwise didn't get mounted very strangely.
@@ -365,6 +371,7 @@ for vol in q a o i; do
   done
   stale_dir=/nocow/btrfs-stale
   rm -f $stale_dir/$d
+
 done
 
 ### disabled