mybin

my ~/bin
git clone https://a3nm.net/git/mybin/
Log | Files | Refs | README

btrfs_incremental_send (589B)


      1 #!/bin/bash
      2 
      3 # send all subvolumes incrementally from SOURCE to DEST
      4 
      5 set -e
      6 
      7 SOURCE="$1"
      8 DEST="$2"
      9 
     10 paste <(ls "$SOURCE" ) <(ls "$SOURCE" | sed 1d) | sed '$d' |
     11 while read l; do
     12   PARENT=$(echo "$l" | cut -f1);
     13   VOLUME=$(echo "$l" | cut -f2);
     14   if [ ! -d "$DEST/$VOLUME" ]
     15   then
     16     if [ ! -d "$DEST/$PARENT" ]
     17     then
     18       echo "putative parent $DEST/$PARENT does not exist on destination!"
     19       exit 2
     20     fi
     21     echo "[($SOURCE/$PARENT) $SOURCE/$VOLUME => $DEST/$VOLUME]"
     22     sudo btrfs send -p "$SOURCE/$PARENT" "$SOURCE/$VOLUME" |
     23     pv | sudo btrfs receive "$DEST"
     24   fi
     25 done
     26