June 19, 2015 · zfs Linux sysadmin

Copy zfs filesystems

Sometime I need to copy/migrate zfs file systems across a network ( backups ) or on the same server ( for testing or upgrades of single devices ).
The process is pretty simple.

Create a zfs snapshop

 zfs snapshot zfs-pool/zfs-volume@base

Now send this snapshot to the device or remote system ( I use pv to show me the progress )


 zfs send zfs-pool/zfs-volume@base | pv | zfs receive zfs-pool/new-zfs-volume


zfs send zfs-pool/zfs-volume@base | pv | ssh root@remote-host “zfs receive zfs-pool/new-zfs-volume”

Sync incremental changes ( if needed ) by creating a new snapshot

zfs snapshot zfs-pool/zfs-volume@latest

Then sending the incremental changes
-i means send the diffs between snaphosts ( in this example the diff between zfs-pool/zfs-volume@base zfs-pool/zfs-volume@latest )
-F means receive the diff and apply it even if the destination volume has changed

zfs send -i zfs-pool/zfs-volume@base zfs-pool/zfs-volume@latest | pv | zfs receive -F zfs-pool/new-zfs-volume