To send a ZFS snapshot to another server, use the zfs send command to create a snapshot stream and pipe it over SSH to the zfs recv command on the destination server. The basic command is zfs send <pool>/<dataset>@<snapshot> | ssh user@remote_host zfs recv <pool>/<dataset>, but you can use flags like -R for a recursive replication stream, -i or -I for incremental snapshots, or add compression like gzip for bandwidth-constrained environments.
Before you start:
- Establish a pool on the destination server: The receiving server must have a ZFS pool set up to store the incoming data.
- Ensure SSH connectivity: Make sure you can SSH from the source to the destination server and have appropriate user permissions on both ends.
- Take a snapshot on the source:
Use
zfs snapshot <source_pool>/<dataset>@<snapshot_name>on the source server to create the snapshot you want to send.
Full Replication (Initial Backup)
This sends the entire dataset with all its properties and descendants.
Code
# On the source server:zfs send -R <source_pool>/<dataset>@<full_snapshot> | ssh <user>@<remote_host> zfs recv -F <destination_pool>/<dataset>
-R: Sends a recursive replication stream, preserving properties, snapshots, and descendant file systems.-F: (On the receiving side) Rollbacks the target if necessary and expands the target pool to match the source.
Incremental Backup
This sends only the changes between two snapshots, which is much more efficient for subsequent backups.
Code
# On the source server:zfs send -i <source_pool>/<dataset>@<previous_snapshot> <source_pool>/<dataset>@<new_snapshot> | ssh <user>@<remote_host> zfs recv -F <destination_pool>/<dataset>
-i: Sends an incremental stream from the<previous_snapshot>to the<new_snapshot>.
Example with Compression
For limited bandwidth, you can add compression to the pipeline.
Code
# On the source server:zfs send -i <previous_snapshot> <new_snapshot> | gzip | ssh <user>@<remote_host> "gunzip | zfs recv -F"
gzip: Compresses the data stream on the sending side.gunzip | zfs recv -F: Decompresses the data on the receiving side before it’s received byzfs recv.
zfs list
zfs snapshot rpool/USERDATA/home_dpwraq@home_20250916
sudo zfs send -R rpool/USERDATA/home_dpwraq@home_20250916 | pv | ssh nexus zfs recv -F zfs10/gearboxsnapshots