After replicating ZFS snapshots on two TrueNAS platforms, the destination dataset inherits the source dataset encryption properties resulting unlocking that dataset on the destination with the original decryption key. In my scenario, my source and destination datasets have different encryption keys. My desired outcome is to unlock all child datasets with the parent dataset with a single encryption key.
You can set each childset in the GUI manually but that is too time-consuming on a regular basis. Instead, I created a zsh snippet to set child datasets to inherit the parent’s encryption properties.
Please edit the below script to reflect your dataset name. ie replace “tank/backups”
while IFS= read -r line; do
echo "Setting ZFS Encrpytion inheritance on -> $line"
sudo zfs change-key -i $line
done < <(sudo zfs list -r -H -t filesystem -o name,encryptionroot tank/backups | awk '{print $1}')
sudo zfs list -r -t filesystem -o name,encryptionroot tank/backups