7 Usage: $0 DATASET@SNAPPREFIX snap-initial
8 $0 DATASET@SNAPPREFIX snap
9 $0 DATASET@SNAPPREFIX sync-initial DST
10 $0 DATASET@SNAPPREFIX sync DST
11 $0 DATASET@SNAPPREFIX clean COUNT
16 enccmd="gpg --compress-level 0 --encrypt --recipient offline --cipher-algo AES-128"
18 [[ $# -ge 2 ]] || usage
23 now=$(date "+%Y%m%d%H%M")
24 depth=${#${(s./.)what}}
25 snaps=$(zfs list -t snap -d $depth -o name -H | grep $what | sort -nr)
28 latest_filename=${latest:gs#/#%}
32 zfs snap -r $what-$now
37 [[ "$what-$now" != $latest ]]
38 zfs snap -r $what-$now
43 [[ -d $dst ]] || usage
45 zfs send -Rv $latest | zstd | ${=enccmd} > \
46 $dst/$latest_filename.zfs.zst.gpg
48 touch $dst/$latest_filename.from
52 [[ -d $dst ]] || usage
53 latest_dst=($dst/*(.Onn[1]))
55 latest_dst=${latest_dst[1]}
56 latest_dst=${${latest_dst##*/}%.from}
57 [[ $latest_dst != $latest_filename ]]
59 zfs send -Rv -i ${latest_dst:gs#%#/} $latest | zstd | ${=enccmd} > \
60 $dst/$latest_filename.zfs.zst.gpg
62 print $latest_dst > $dst/$latest_filename.from
66 [[ -n $count ]] || usage
67 count=$(( $count + 1 ))
68 for snap in $snaps ; do
69 count=$(( $count - 1 ))
70 [[ $count -le 0 ]] || continue