Managing ZFS File Systems in Oracle® Solaris 11.2

Exit Print View

Updated: December 2014
 
 

Applying Different Property Values to a ZFS Snapshot Stream

You can send a ZFS snapshot stream with a certain file system property value, but you can specify a different local property value when the snapshot stream is received. Or, you can specify that the original property value be used when the snapshot stream is received to re-create the original file system. In addition, you can disable a file system property when the snapshot stream is received.

  • Use the zfs inherit –S to revert a local property value to the received value, if any. If a property does not have a received value, the behavior of the zfs inherit –S command is the same as the zfs inherit command without the –S option. If the property does have a received value, the zfs inherit command masks the received value with the inherited value until issuing a zfs inherit –S command reverts it to the received value.

  • You can use the zfs get –o to include the new non-default RECEIVED column. Or, use the zfs get –o all command to include all columns, including RECEIVED.

  • You can use the zfs send –p option to include properties in the send stream without the –R option.

  • You can use the zfs receive –e option to use the last element of the sent snapshot name to determine the new snapshot name. The following example sends the poola/bee/cee@1 snapshot to the poold/eee file system and only uses the last element (cee@1) of the snapshot name to create the received file system and snapshot.

    # zfs list -rt all poola
    NAME              USED  AVAIL  REFER  MOUNTPOINT
    poola             134K   134G    23K  /poola
    poola/bee          44K   134G    23K  /poola/bee
    poola/bee/cee      21K   134G    21K  /poola/bee/cee
    poola/bee/cee@1      0      -    21K  -
    # zfs send -R poola/bee/cee@1 | zfs receive -e poold/eee
    # zfs list -rt all poold
    NAME              USED  AVAIL  REFER  MOUNTPOINT
    poold             134K   134G    23K  /poold
    poold/eee          44K   134G    23K  /poold/eee
    poold/eee/cee      21K   134G    21K  /poold/eee/cee
    poold/eee/cee@1      0      -    21K  -

In some cases, file system properties in a send stream might not apply to the receiving file system or local file system properties, such as the mountpoint property value, might interfere with a restore.

For example, the tank/data file system has the compression property disabled. A snapshot of the tank/data file system is sent with properties (–p option) to a backup pool and is received with the compression property enabled.

# zfs get compression tank/data
NAME       PROPERTY     VALUE     SOURCE
tank/data  compression  off       default
# zfs snapshot tank/data@snap1
# zfs send -p tank/data@snap1 | zfs recv -o compression=on -d bpool
# zfs get -o all compression bpool/data
NAME        PROPERTY     VALUE     RECEIVED  SOURCE
bpool/data  compression  on        off       local

In the example, the compression property is enabled when the snapshot is received into bpool. So, for bpool/data, the compression value is on.

If this snapshot stream is sent to a new pool, restorepool, for recovery purposes, you might want to keep all the original snapshot properties. In this case, you would use the zfs send –b command to restore the original snapshot properties. For example:

# zfs send -b bpool/data@snap1 | zfs recv -d restorepool
# zfs get -o all compression restorepool/data
NAME              PROPERTY     VALUE     RECEIVED  SOURCE
restorepool/data  compression  off       off       received 

In the example, the compression value is off, which represents the snapshot compression value from the original tank/data file system.

If you have a local file system property value in a snapshot stream and you want to disable the property when it is received, use the zfs receive –x command. For example, the following command sends a recursive snapshot stream of home directory file systems with all file system properties reserved to a backup pool, but without the quota property values:

# zfs send -R tank/home@snap1 | zfs recv -x quota bpool/home
# zfs get -r quota bpool/home
NAME                   PROPERTY  VALUE  SOURCE
bpool/home             quota     none   local
bpool/home@snap1       quota     -      -
bpool/home/lori        quota     none   default
bpool/home/lori@snap1  quota     -      -
bpool/home/mark        quota     none   default
bpool/home/mark@snap1  quota     -      -

If the recursive snapshot was not received with the –x option, the quota property would be set in the received file systems.

# zfs send -R tank/home@snap1 | zfs recv bpool/home
# zfs get -r quota bpool/home
NAME                   PROPERTY  VALUE  SOURCE
bpool/home             quota     none   received
bpool/home@snap1       quota     -      -
bpool/home/lori        quota     10G    received
bpool/home/lori@snap1  quota     -      -
bpool/home/mark        quota     10G    received
bpool/home/mark@snap1  quota     -      -