5 Usage: $0 DATASET@SNAPPREFIX snap-initial
6 $0 DATASET@SNAPPREFIX snap
7 $0 DATASET@SNAPPREFIX sync-initial DST
8 $0 DATASET@SNAPPREFIX sync DST
9 $0 DATASET@SNAPPREFIX clean COUNT
14 enccmd="gpg --compress-level 0 --encrypt --recipient offline --cipher-algo AES-128"
21 now=$(date "+%Y%m%d%H%M")
22 snaps=$(zfs list -t snap -d 1 -o name -H | grep $what | sort -nr)
23 latest=$(echo $snaps | sed -n 1p)
27 zfs snap -r $what-$now
32 [ "$what-$now" != "$latest" ]
33 zfs snap -r $what-$now
38 [ -d "$dst" ] || usage
40 zfs send -Rv $latest | zstd | ${=enccmd} > $dst/$latest.zfs.zst.gpg
42 touch $dst/$latest.from
46 [ -d "$dst" ] || usage
47 latest_dst=$(find $dst -type f -name "*.from" | sort -rn | sed -n 1p)
49 latest_dst=$(basename ${latest_dst%.from})
50 [ "$latest_dst" != "$latest" ]
52 zfs send -Rv -i $latest_dst $latest | zstd | ${=enccmd} > $dst/$latest.zfs.zst.gpg
54 echo "$latest_dst" > $dst/$latest.from
58 [ -n "$count" ] || usage
59 count=$(( $count + 1 ))
60 for snap in $(echo $snaps) ; do
61 count=$(( $count - 1 ))
62 [ $count -le 0 ] || continue