ZFS Remote Sync

From RoseWiki
Jump to navigation Jump to search

It is possible to sync one zpool's contents to another via zfs send and zfs recv.

First, create a snapshot of the data you want to send. To copy an entire zpool, create a snapshot with the following command:

zpool snapshot -r [zpool_to_snapshot]@[snapshot_name]

You can also snapshot a specific subvol.

zpool snapshot [zpool_to_snapshot/with_sub_vol]@[snapshot_name] 

We'll be sending the data from this snapshot over to another host using zfs send and zfs recv. We'll want to run this command in a screen session in case our terminal disconnects. We pipe the output of zfs send into an ssh connection running zfs recv.

We run zfs send with -R to send all content under the specified snapshot. We run zfs recv with the flags -F (expand and replace) -d (discard target name and replace with source) -u (do not mount on destination). The pool must exist on the destination. Essentially, we're not cloning the ZFS configuration, we're funneling information on a higher level between them, in the same sense that one might SCP or rsync data. We recommend using zpool set autoexpand=on [pool_name]

zfs send -R [zpool_to_clone]@[snapshot_name] | ssh [destination_IP] zfs recv -Fdu [destination_pool]

This will take quite some time. It may take multiple days, depending on the size of your dataset.