Difference between revisions of "Documentation/ZfsSend"

From OpenZFS
Jump to navigation Jump to search
Line 8: Line 8:


<code>
<code>
$ zfs create rpool/send-test
$ zfs create rpool/send-test<br />
$ touch /rpool/send-test/tmp
$ touch /rpool/send-test/tmp<br />
$ zfs snapshot rpool/send-test@before
$ zfs snapshot rpool/send-test@before<br />
$ echo 123 > /rpool/send-test/tmp
$ echo 123 > /rpool/send-test/tmp<br />
$ zfs snapshot rpool/send-test@after
$ zfs snapshot rpool/send-test@after<br />
$ zfs send -i rpool/send-test@before rpool/send-test@after > send.log
$ zfs send -i rpool/send-test@before rpool/send-test@after > send.log<br />
</code>
</code>

Revision as of 17:54, 30 August 2013

ZFS send and receive are used to replicate filesystem and volumes within or between ZFS pools, including pools which are in physically different locations. ZFS send generates send streams which contain file data from the filesystem or volume being replicated. These send streams can either be “full”, containing all data in a given snapshot, or “incremental”, containing only the differences between two snapshots. ZFS receive reads these send streams and uses them to re-create identical snapshots on a receiving system. ZFS send and receive are designed to minimize the need for communication between the sender and receiver and optimize the ability of the sender to determine which blocks need to be sent. These basic primitives provide the basis for building powerful data replication systems on top of ZFS.

ZFS send streams consist of records which describe writes or frees the receiving end should perform in order to recreate the sent snapshot. For example, a WRITE record could indicate that the contents of the 5th block of the file with object number 1534 should be updated. A very simple send stream is depicted below. When generating this stream the records are written to a file descriptor. When using the zfs send command this file descriptor is stdout.

SendStreamFormat.png

The zstreamdump command can be used to print send stream contents in a human-readable format. As an example, we can create a ZFS filesystem, place an empty file in it, snapshot it, modify that file, then snapshot it again, and send the changes between the first and second snapshot to a file:

$ zfs create rpool/send-test
$ touch /rpool/send-test/tmp
$ zfs snapshot rpool/send-test@before
$ echo 123 > /rpool/send-test/tmp
$ zfs snapshot rpool/send-test@after
$ zfs send -i rpool/send-test@before rpool/send-test@after > send.log