Types of ZFS Snapshot Streams

The zfs send command can be used to create a stream of one or more snapshots. Then, you can use the snapshot stream to re-create a ZFS file system or volume by using the zfs receive command.

The zfs send options used to create the snapshot stream determine the stream format type that is generated.

  • Full stream – Consists of all dataset content from the time that the dataset was created up to the specified snapshot.

    The default stream generated by the zfs send command is a full stream. It contains one file system or volume, up to and including the specified snapshot. The stream does not contain snapshots other than the snapshot specified in the command.

  • Incremental stream – Consists of the differences between one snapshot and another snapshot.

A stream package is a stream type that contains one or more full or incremental streams. The types of stream packages are:

  • Replication stream package – Consists of the specified dataset and its descendants. It includes all intermediate snapshots. If the origin of a cloned dataset is not a descendant of the snapshot specified on the command line, that origin dataset is not included in the stream package. To receive the stream, the origin dataset must exist in the destination storage pool.

    Note:

    A self-contained replication stream does not have external dependencies. See the section on self-contained replication streams below.

    Assume that the following list of datasets and their origins were created in the order in which they appear.

    NAME                    ORIGIN
    pool/a                  -
    pool/a/1                -
    pool/a/1@clone          -
    pool/b                  -
    pool/b/1                pool/a/1@clone
    pool/b/1@clone2         -
    pool/b/2                pool/b/1@clone2
    pool/b@pre-send         -
    pool/b/1@pre-send       -
    pool/b/2@pre-send       -
    pool/b@send             -
    pool/b/1@send           -
    pool/b/2@send           -

    Suppose you have a replication stream package created with the following syntax:

    $ zfs send -R pool/b@send ....

    This package would consist of the following full and incremental streams:

    TYPE    SNAPSHOT                INCREMENTAL FROM
    full    pool/b@pre-send         -
    incr    pool/b@send             pool/b@pre-send
    incr    pool/b/1@clone2         pool/a/1@clone
    incr    pool/b/1@pre-send       pool/b/1@clone2
    incr    pool/b/1@send           pool/b/1@send
    incr    pool/b/2@pre-send       pool/b/1@clone2
    incr    pool/b/2@send           pool/b/2@pre-send

    In the output, the pool/a/1@clone snapshot is not included in the replication stream package. Therefore, this replication stream package can only be received in a pool that already has pool/a/1@clone snapshot.

  • Self-contained replication stream package - This type of package is not dependent on any datasets that are not included in the stream package. You create a replication stream package with syntax similar to the following example:

    $ zfs send -Rc pool/b@send ...

    This example package would consist of the following full and incremental streams:

    TYPE    SNAPSHOT             INCREMENTAL FROM 
    full    pool/b@pre-send      - 
    full    pool/b/1@clone2      - 
    incr    pool/b@send          pool/b@pre-send
    incr    pool/b/1@pre-send    pool/b/1@clone2 
    incr    pool/b/1@send        pool/b/1@send 
    incr    pool/b/2@pre-send    pool/b/1@clone2 
    incr    pool/b/2@send        pool/b/2@pre-send 

    Comparing with the non-self-contained replication stream, notice that this self-contained replication stream has an integrated full stream of the pool/b/1@clone2 snapshot. This snapshot is an integrated dataset that has clone origin bits merged into it as data; clone2 is no longer a full clone with a separate origin. This makes it possible to receive the pool/b/1 snapshot with no external dependencies.

  • Recursive stream package – Consists of the specified dataset and its descendants. Unlike replication stream packages, intermediate snapshots are not included unless they are the origin of a cloned dataset that is included in the stream. By default, if the origin of a dataset is not a descendant of the snapshot specified in the command, the behavior is similar to replication streams. Note that a self-contained recursive stream does not have external dependencies.

    Note:

    A self-contained recursive stream does not have external dependencies. See the section on self-contained recursive streams below.

    You create a recursive stream package with syntax similar to the following example:

    $ zfs send -r pool/b@send ... 

    This example package would consist of the following full and incremental streams:

    TYPE    SNAPSHOT                INCREMENTAL FROM
    full    pool/b@send             -
    incr    pool/b/1@clone2         pool/a/1@clone
    incr    pool/b/1@send           pool/b/1@clone2
    incr    pool/b/2@send           pool/b/1@clone2

    In the output, the pool/a/1@clone snapshot is not included in the recursive stream package. Therefore, similar to the replication stream package,this recursive stream package can only be received in a pool that already has pool/a/1@clone snapshot. This behavior is similar to the replication stream package scenario described above.

  • Self-contained recursive stream package - This type of package is not dependent on any datasets that are not included in the stream package. You create a recursive stream package with syntax similar to the following example:

    $ zfs send -rc pool/b@send ...

    This example package would consist of the following full and incremental streams:

    TYPE    SNAPSHOT                INCREMENTAL FROM
    full    pool/b@send             -
    full    pool/b/1@clone2         -
    incr    pool/b/1@send           pool/b/1@clone2 
    incr    pool/b/2@send           pool/b/1@clone2