]> Sergey Matveev's repositories - dotfiles.git/commitdiff
Ability to send backup via FIFO
authorSergey Matveev <stargrave@stargrave.org>
Mon, 23 Oct 2023 12:34:02 +0000 (15:34 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Mon, 23 Oct 2023 12:34:02 +0000 (15:34 +0300)
bin/bin/zsnap

index ec23ea54034ac2c7653b747169141a597a9dd623..008fd079bab5038b91244ffed4ba14d54dd4f74a 100755 (executable)
@@ -10,6 +10,7 @@ Usage: $0 DATASET@SNAPPREFIX snap-initial
        $0 DATASET@SNAPPREFIX sync-initial DST
        $0 DATASET@SNAPPREFIX sync DST
        $0 DATASET@SNAPPREFIX clean COUNT
+       FIFO=1
 EOF
     exit 1
 }
@@ -28,6 +29,11 @@ snaps=$(zfs list -t snap -d $depth -o name -H | grep $what | sort -nr)
 snaps=(${(f)snaps})
 latest=${snaps[1]}
 latest_filename=${latest:gs#/#%}
+dst=$3
+[[ -z $FIFO ]] || {
+    mkfifo $dst/$latest_filename.zfs.zst.age
+    echo $dst/$latest_filename.zfs.zst.age
+}
 
 case $action in
     snap-initial)
@@ -41,15 +47,13 @@ case $action in
         print $what-$now
         ;;
     sync-initial)
-        dst=$3
         [[ -d $dst ]] || usage
         setopt PIPE_FAIL
-        zfs send -Rwv $latest | zstd | $enccmd > $dst/$latest_filename.zfs.zst.age
+        zfs send -Rwv $latest | zstdmt | $enccmd > $dst/$latest_filename.zfs.zst.age
         sync
         touch $dst/$latest_filename.from
         ;;
     sync)
-        dst=$3
         [[ -d $dst ]] || usage
         latest_dst=($dst/*.from~$dst/.*(.Onn[1]))
         [[ $latest_dst ]]
@@ -58,7 +62,7 @@ case $action in
         [[ $latest_dst != $latest_filename ]]
         setopt PIPE_FAIL
         set -x
-        zfs send -Rwv -i ${latest_dst:gs#%#/} $latest | zstd | $enccmd > \
+        zfs send -Rwv -i ${latest_dst:gs#%#/} $latest | zstdmt | $enccmd > \
             $dst/$latest_filename.zfs.zst.age
         set +x
         sync