From 67350ba27ae35c0c5295c85aa2dc8bdad1cbb6c9 Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Mon, 23 Oct 2023 15:34:02 +0300 Subject: [PATCH] Ability to send backup via FIFO --- bin/bin/zsnap | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/bin/bin/zsnap b/bin/bin/zsnap index ec23ea5..008fd07 100755 --- a/bin/bin/zsnap +++ b/bin/bin/zsnap @@ -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 -- 2.44.0