|ZFS-RECEIVE(8)||System Manager's Manual||ZFS-RECEIVE(8)|
create snapshot from backup stream
- Creates a snapshot whose contents are as specified in the stream provided
on standard input. If a full stream is received, then a new file system is
created as well. Streams are created using the
sendsubcommand, which by default creates a full stream.
recvcan be used as an alias for
If an incremental stream is received, then the destination file system must already exist, and its most recent snapshot must match the incremental stream's source. For zvols, the destination device link is destroyed and recreated, which means the zvol cannot be accessed during the
When a snapshot replication package stream that is generated by using the
-Rcommand is received, any snapshots that do not exist on the sending location are destroyed by using the
The ability to send and receive deduplicated send streams has been removed. However, a deduplicated send stream created with older software can be converted to a regular (non-deduplicated) stream by using the
-xproperty is specified, it applies to the effective value of the property throughout the entire subtree of replicated datasets. Effective property values will be set (
-o) or inherited (
-x) on the topmost in the replicated subtree. In descendant datasets, if the property is set by the send stream, it will be overridden by forcing the property to be inherited from the top‐most file system. Received properties are retained in spite of being overridden and may be restored with
-oorigin=snapshot is a special case because, even if origin is a read-only property and cannot be set, it's allowed to receive the send stream as a clone of the given snapshot.
Raw encrypted send streams (created with
-w) may only be received as is, and cannot be re-encrypted, decrypted, or recompressed by the receive process. Unencrypted streams can be received as encrypted datasets, either through inheritance or by specifying encryption parameters with the
-ooptions. Note that the keylocation property cannot be overridden to prompt during a receive. This is because the receive process itself is already using the standard input for the send stream. Instead, the property can be overridden after the receive completes.
The added security provided by raw sends adds some restrictions to the send and receive process. ZFS will not allow a mix of raw receives and non-raw receives. Specifically, any raw incremental receives that are attempted after a non-raw receive will fail. Non-raw receives do not have this restriction and, therefore, are always possible. Because of this, it is best practice to always use either raw sends for their security benefits or non-raw sends for their flexibility when working with encrypted datasets, but not a combination.
The reason for this restriction stems from the inherent restrictions of the AEAD ciphers that ZFS uses to encrypt data. When using ZFS native encryption, each block of data is encrypted against a randomly generated number known as the "initialization vector" (IV), which is stored in the filesystem metadata. This number is required by the encryption algorithms whenever the data is to be decrypted. Together, all of the IVs provided for all of the blocks in a given snapshot are collectively called an "IV set". When ZFS performs a raw send, the IV set is transferred from the source to the destination in the send stream. When ZFS performs a non-raw send, the data is decrypted by the source system and re-encrypted by the destination system, creating a snapshot with effectively the same data, but a different IV set. In order for decryption to work after a raw send, ZFS must ensure that the IV set used on both the source and destination side match. When an incremental raw receive is performed on top of an existing snapshot, ZFS will check to confirm that the "from" snapshot on both the source and destination were using the same IV set, ensuring the new IV set is consistent.
The name of the snapshot (and file system, if a full stream is received) that this subcommand creates depends on the argument type and the use of the
If the argument is a snapshot name, the specified snapshot is created. If the argument is a file system or volume name, a snapshot with the same name as the sent snapshot is created within the specified filesystem or volume. If neither of the
-eoptions are specified, the provided target snapshot name is used exactly as provided.
-eoptions cause the file system name of the target snapshot to be determined by appending a portion of the sent snapshot's name to the specified target filesystem. If the
-doption is specified, all but the first element of the sent snapshot's file system path (usually the pool name) is used and any required intermediate file systems within the specified one are created. If the
-eoption is specified, then only the last element of the sent snapshot's file system name (i.e. the name of the source file system itself) is used as the target file system name.
- Force a rollback of the file system to the most recent snapshot before
performing the receive operation. If receiving an incremental
replication stream (for example, one generated by
-I]), destroy snapshots and file systems that do not exist on the sending side.
- Discard the first element of the sent snapshot's file system name, using the remaining elements to determine the name of the target file system for the new snapshot as described in the paragraph above.
- Discard all but the last element of the sent snapshot's file system name, using that element to determine the name of the target file system for the new snapshot as described in the paragraph above.
- Skip the receive of holds. There is no effect if holds are not sent.
- Force an unmount of the file system while receiving a snapshot. This option is not supported on Linux.
- Do not actually receive the stream. This can be useful in conjunction
-voption to verify the name the receive operation would use.
- Forces the stream to be received as a clone of the given snapshot. If the stream is a full send stream, this will create the filesystem described by the stream as a clone of the specified snapshot. Which snapshot was specified will not affect the success or failure of the receive, as long as the snapshot does exist. If the stream is an incremental send stream, all the normal verification will be performed.
- Sets the specified property as if the command
setproperty=value was invoked immediately before the receive. When receiving a stream from
-R, causes the property to be inherited by all descendant datasets, as through
inheritproperty was run on any descendant datasets that have this property set on the sending system.
If the send stream was sent with
-cthen overriding the compression property will have no effect on received data but the compression property will be set. To have the data recompressed on receive remove the
-cflag from the send stream.
Any editable property can be set at receive time. Set-once properties bound to the received data, such as normalization and casesensitivity, cannot be set at receive time even when the datasets are newly created by
receive. Additionally both settable properties version and volsize cannot be set at receive time.
-ooption may be specified multiple times, for different properties. An error results if the same property is specified in multiple
-ooption may also be used to override encryption properties upon initial receive. This allows unencrypted streams to be received as encrypted datasets. To cause the received dataset (or root dataset of a recursive stream) to be received as an encryption root, specify encryption properties in the same manner as is required for
create. For instance:
-okeylocation=prompt may not be specified here, since the standard input is already being utilized for the send stream. Once the receive has completed, you can use
setto change this setting after the fact. Similarly, you can receive a dataset as an encrypted child by specifying
-xencryption to force the property to be inherited. Overriding encryption properties (except for keylocation) is not possible with raw send streams.
- If the receive is interrupted, save the partially received state,
rather than deleting it. Interruption may be due to premature
termination of the stream (e.g. due to network failure or failure of
the remote system if the stream is being read over a network
connection), a checksum error in the stream, termination of the
receiveprocess, or unclean shutdown of the system.
The receive can be resumed with a stream generated by
-ttoken, where the token is the value of the receive_resume_token property of the filesystem or volume which is received into.
To use this flag, the storage pool must have the extensible_dataset feature enabled. See zpool-features(7) for details on ZFS feature flags.
- File system that is associated with the received stream is not mounted.
- Print verbose information about the stream and the time required to perform the receive operation.
- Ensures that the effective value of the specified property after the
receive is unaffected by the value of that property in the send stream
(if any), as if the property had been excluded from the send stream.
If the specified property is not present in the send stream, this option does nothing.
If a received property needs to be overridden, the effective value will be set or inherited, depending on whether the property is inheritable or not.
In the case of an incremental update,
-xleaves any existing local setting or explicit inheritance unchanged.
-orestrictions (e.g. set-once) apply equally to
- Abort an interrupted
-s, deleting its saved partially received state.
- Attempt to repair data corruption in the specified dataset, by using the
provided stream as the source of healthy data. This method of healing can
only heal data blocks present in the stream. Metadata can not be healed by
corrective receive. Running a scrub is recommended post-healing to ensure
all data corruption was repaired.
It's important to consider why corruption has happened in the first place. If you have slowly failing hardware - periodically repairing the data is not going to save you from data loss later on when the hardware fails completely.
Example 1: Remotely Replicating ZFS Data
The following commands send a full stream and then an incremental stream to a remote machine, restoring them into poolB/received/fs@a and poolB/received/fs@b, respectively. poolB must contain the file system poolB/received, and must not initially contain poolB/received/fs.
-ia pool/fs@b |
2: Using the
The following command sends a full stream of poolA/fsA/fsB@snap to a remote machine, receiving it into poolB/received/fsA/fsB@snap. The fsA/fsB@snap portion of the received snapshot's name is determined from the name of the sent snapshot. poolB must contain the file system poolB/received. If poolB/received/fsA does not exist, it is created as an empty file system.
|March 12, 2023||Debian|