8 Usage: $0 DATASET@SNAPPREFIX snap-initial
9 $0 DATASET@SNAPPREFIX snap
10 $0 DATASET@SNAPPREFIX sync-initial DST
11 $0 DATASET@SNAPPREFIX sync DST
12 $0 DATASET@SNAPPREFIX clean COUNT
17 enccmd=(~stargrave/bin/gpg-e-fast.sh --recipient offline)
19 [[ $# -ge 2 ]] || usage
24 now=$(date "+%Y%m%d%H%M")
25 [[ $what =~ / ]] && depth=1 || depth=${#${(s./.)what}}
26 snaps=$(zfs list -t snap -d $depth -o name -H | grep $what | sort -nr)
29 latest_filename=${latest:gs#/#%}
33 zfs snap -r $what-$now
38 [[ "$what-$now" != $latest ]]
39 zfs snap -r $what-$now
44 [[ -d $dst ]] || usage
46 zfs send -Rv $latest | zstd | $enccmd > $dst/$latest_filename.zfs.zst.gpg
48 touch $dst/$latest_filename.from
52 [[ -d $dst ]] || usage
53 latest_dst=($dst/*~$dst/.*(.L0Onn[1]))
55 latest_dst=${latest_dst[1]}
56 latest_dst=${${latest_dst##*/}%.from}
57 [[ $latest_dst != $latest_filename ]]
60 zfs send -Rv -i ${latest_dst:gs#%#/} $latest | zstd | $enccmd > \
61 $dst/$latest_filename.zfs.zst.gpg
64 print $latest_dst > $dst/$latest_filename.from
68 [[ -n $count ]] || usage
69 count=$(( $count + 1 ))
70 for snap in $snaps ; do
71 count=$(( $count - 1 ))
72 [[ $count -le 0 ]] || continue