Syncing all ZFS snapshots

It’s 2019 and Netapp still rightfully has market share because it’s the only vendor that has snapmirror technology.

Common scenario: you have to sites, and you want to have both data volume snapshots and replication between two sites.

Apparently ZFS can readily do both as it makes easy to both create snapshots and send them around.

BUT: if you propagate the snapshots one by one, as you create them, then it’s fine.

Otherwise, there’s (apparently) no way of bulk-sending all the snapshots.

I’ve tried messing up with the -i (for incremental) option of zfs send, but it can only send the immediately-following snapshot of a snapshot. If like me you have 30-40 snapshots of a single dataset, you’re out of luck.

In this post, thus, I will be describing what I came up with to automate the sending of all the snapshots from a machine to another, using zfs. Make sure to make the adequate alterations and customization when/where needed.

Legend of hosnames and stuff

From here on, the following names will have the associated meaning

source: the already existing machine that currently hosts the zfs pool, the zfs dataset and all the volumes

destination: the new machine that has a new zpool with an empty dataset and no snapshot

Short version:

First things first, receive the first snapshot (basically most of the dataset) onto the destination: