KB450095 – ZFS Send-Recieve with Netcat

Last modified: July 16, 2021
You are here:
Table of Contents

The general way to send ZFS data sets to remote nodes is normally achieved by sending the ZFS stream through ssh.  The down side with this method is that ssh encryption is slow and has significant cpu overhead. You may find yourself in situations where you have very large datasets that you need to move from one ZFS host to another and you want it to be as fast as possible with as little cpu overhead as possible. The following method is good for local environments where you are not concerned about sending streams unencrypted. The tool that works very well for this is “netcat“.

Set Up

This script does not create snapshots, it only sends them. At least 1 snapshot must be created for this script to run.

Create periodic snapshot task in the FreeNAS UI, or manually create a snapshot before running this script.

This script is designed to be used for initial data migration, not for periodic sending/receiving. This process sends an unencrypted stream of data over the network and should only be used in a secure environment

The most basic set up is the following:

curl -LO http://images.45drives.com/FreeNAS/scripts/zfs-send-recv-nc.sh
sh zfs-send-recv-nc.sh -s <volume/dataset> -n <remote_host>

This will find the most recent local snapshot of the specified volume/dataset and stream it to the specified remote host.
By default this script will assume the receiving volume/dataset has the same name as the sender. To use a different volume/dataset on the receiver use the “-v” flag.
For example,

  • A local volume: tank/dataset1
  • A remote host @
  • A remote volume: tank/backups
sh zfs-send-recv-nc.sh -s tank/dataset1 -r tank/backups -n

Performance Gains

Network throughput

SSH zfs send-recv = 30MB/s

Netcat zfs send-recv = 741MB/s

Was this article helpful?
Dislike 1
Views: 859
Unboxing Racking Storage Drives Cable Setup Power UPS Sizing Remote Access