4 .\" The contents of this file are subject to the terms of the
5 .\" Common Development and Distribution License (the "License").
6 .\" You may not use this file except in compliance with the License.
8 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 .\" or https://opensource.org/licenses/CDDL-1.0.
10 .\" See the License for the specific language governing permissions
11 .\" and limitations under the License.
13 .\" When distributing Covered Code, include this CDDL HEADER in each
14 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 .\" If applicable, add the following below this CDDL HEADER, with the
16 .\" fields enclosed by brackets "[]" replaced with your own identifying
17 .\" information: Portions Copyright [yyyy] [name of copyright owner]
21 .\" Copyright (c) 2009 Sun Microsystems, Inc. All Rights Reserved.
22 .\" Copyright 2011 Joshua M. Clulow <josh@sysmgr.org>
23 .\" Copyright (c) 2011, 2019 by Delphix. All rights reserved.
24 .\" Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
25 .\" Copyright (c) 2014, Joyent, Inc. All rights reserved.
26 .\" Copyright (c) 2014 by Adam Stevko. All rights reserved.
27 .\" Copyright (c) 2014 Integros [integros.com]
28 .\" Copyright 2019 Richard Laager. All rights reserved.
29 .\" Copyright 2018 Nexenta Systems, Inc.
30 .\" Copyright 2019 Joyent, Inc.
38 .Nd create snapshot from backup stream
43 .Op Fl o Sy origin Ns = Ns Ar snapshot
44 .Op Fl o Ar property Ns = Ns Ar value
46 .Ar filesystem Ns | Ns Ar volume Ns | Ns Ar snapshot
51 .Op Fl o Sy origin Ns = Ns Ar snapshot
52 .Op Fl o Ar property Ns = Ns Ar value
58 .Ar filesystem Ns | Ns Ar volume
63 .Ar filesystem Ns | Ns Ar snapshot
71 .Op Fl o Sy origin Ns = Ns Ar snapshot
72 .Op Fl o Ar property Ns = Ns Ar value
74 .Ar filesystem Ns | Ns Ar volume Ns | Ns Ar snapshot
81 .Op Fl o Sy origin Ns = Ns Ar snapshot
82 .Op Fl o Ar property Ns = Ns Ar value
86 Creates a snapshot whose contents are as specified in the stream provided on
88 If a full stream is received, then a new file system is created as well.
89 Streams are created using the
91 subcommand, which by default creates a full stream.
93 can be used as an alias for
96 If an incremental stream is received, then the destination file system must
97 already exist, and its most recent snapshot must match the incremental stream's
101 the destination device link is destroyed and recreated, which means the
103 cannot be accessed during the
107 When a snapshot replication package stream that is generated by using the
109 command is received, any snapshots that do not exist on the sending location are
110 destroyed by using the
111 .Nm zfs Cm destroy Fl d
114 The ability to send and receive deduplicated send streams has been removed.
115 However, a deduplicated send stream created with older software can be converted
116 to a regular (non-deduplicated) stream by using the
121 .Fl o Em property Ns = Ns Ar value
124 is specified, it applies to the effective value of the property throughout
125 the entire subtree of replicated datasets.
126 Effective property values will be set
130 on the topmost in the replicated subtree.
131 In descendant datasets, if the
132 property is set by the send stream, it will be overridden by forcing the
133 property to be inherited from the top‐most file system.
134 Received properties are retained in spite of being overridden
135 and may be restored with
136 .Nm zfs Cm inherit Fl S .
138 .Fl o Sy origin Ns = Ns Em snapshot
139 is a special case because, even if
141 is a read-only property and cannot be set, it's allowed to receive the send
142 stream as a clone of the given snapshot.
144 Raw encrypted send streams (created with
145 .Nm zfs Cm send Fl w )
146 may only be received as is, and cannot be re-encrypted, decrypted, or
147 recompressed by the receive process.
148 Unencrypted streams can be received as
149 encrypted datasets, either through inheritance or by specifying encryption
155 property cannot be overridden to
158 This is because the receive process itself is already using
159 the standard input for the send stream.
160 Instead, the property can be overridden after the receive completes.
162 The added security provided by raw sends adds some restrictions to the send
164 ZFS will not allow a mix of raw receives and non-raw receives.
165 Specifically, any raw incremental receives that are attempted after
166 a non-raw receive will fail.
167 Non-raw receives do not have this restriction and,
168 therefore, are always possible.
169 Because of this, it is best practice to always
170 use either raw sends for their security benefits or non-raw sends for their
171 flexibility when working with encrypted datasets, but not a combination.
173 The reason for this restriction stems from the inherent restrictions of the
174 AEAD ciphers that ZFS uses to encrypt data.
175 When using ZFS native encryption,
176 each block of data is encrypted against a randomly generated number known as
177 the "initialization vector" (IV), which is stored in the filesystem metadata.
178 This number is required by the encryption algorithms whenever the data is to
180 Together, all of the IVs provided for all of the blocks in a
181 given snapshot are collectively called an "IV set".
182 When ZFS performs a raw send, the IV set is transferred from the source
183 to the destination in the send stream.
184 When ZFS performs a non-raw send, the data is decrypted by the source
185 system and re-encrypted by the destination system, creating a snapshot with
186 effectively the same data, but a different IV set.
187 In order for decryption to work after a raw send, ZFS must ensure that
188 the IV set used on both the source and destination side match.
189 When an incremental raw receive is performed on
190 top of an existing snapshot, ZFS will check to confirm that the "from"
191 snapshot on both the source and destination were using the same IV set,
192 ensuring the new IV set is consistent.
194 The name of the snapshot
195 .Pq and file system, if a full stream is received
196 that this subcommand creates depends on the argument type and the use of the
202 If the argument is a snapshot name, the specified
205 If the argument is a file system or volume name, a snapshot with the same name
206 as the sent snapshot is created within the specified
214 options are specified, the provided target snapshot name is used exactly as
221 options cause the file system name of the target snapshot to be determined by
222 appending a portion of the sent snapshot's name to the specified target
226 option is specified, all but the first element of the sent snapshot's file
228 .Pq usually the pool name
229 is used and any required intermediate file systems within the specified one are
233 option is specified, then only the last element of the sent snapshot's file
235 .Pq i.e. the name of the source file system itself
236 is used as the target file system name.
239 Force a rollback of the file system to the most recent snapshot before
240 performing the receive operation.
241 If receiving an incremental replication stream
242 .Po for example, one generated by
243 .Nm zfs Cm send Fl R Op Fl i Ns | Ns Fl I
245 destroy snapshots and file systems that do not exist on the sending side.
247 Discard the first element of the sent snapshot's file system name, using the
248 remaining elements to determine the name of the target file system for the new
249 snapshot as described in the paragraph above.
251 Discard all but the last element of the sent snapshot's file system name, using
252 that element to determine the name of the target file system for the new
253 snapshot as described in the paragraph above.
255 Skip the receive of holds.
256 There is no effect if holds are not sent.
258 Force an unmount of the file system while receiving a snapshot.
259 This option is not supported on Linux.
261 Do not actually receive the stream.
262 This can be useful in conjunction with the
264 option to verify the name the receive operation would use.
265 .It Fl o Sy origin Ns = Ns Ar snapshot
266 Forces the stream to be received as a clone of the given snapshot.
267 If the stream is a full send stream, this will create the filesystem
268 described by the stream as a clone of the specified snapshot.
269 Which snapshot was specified will not affect the success or failure of the
270 receive, as long as the snapshot does exist.
271 If the stream is an incremental send stream, all the normal verification will be
273 .It Fl o Em property Ns = Ns Ar value
274 Sets the specified property as if the command
275 .Nm zfs Cm set Em property Ns = Ns Ar value
276 was invoked immediately before the receive.
277 When receiving a stream from
278 .Nm zfs Cm send Fl R ,
279 causes the property to be inherited by all descendant datasets, as through
280 .Nm zfs Cm inherit Em property
281 was run on any descendant datasets that have this property set on the
284 If the send stream was sent with
288 property will have no effect on received data but the
290 property will be set.
291 To have the data recompressed on receive remove the
293 flag from the send stream.
295 Any editable property can be set at receive time.
296 Set-once properties bound
297 to the received data, such as
300 .Sy casesensitivity ,
301 cannot be set at receive time even when the datasets are newly created by
303 Additionally both settable properties
307 cannot be set at receive time.
311 option may be specified multiple times, for different properties.
312 An error results if the same property is specified in multiple
320 option may also be used to override encryption properties upon initial receive.
321 This allows unencrypted streams to be received as encrypted datasets.
322 To cause the received dataset (or root dataset of a recursive stream) to be
323 received as an encryption root, specify encryption properties in the same
324 manner as is required for
327 .Dl # Nm zfs Cm send Pa tank/test@snap1 | Nm zfs Cm recv Fl o Sy encryption Ns = Ns Sy on Fl o Sy keyformat Ns = Ns Sy passphrase Fl o Sy keylocation Ns = Ns Pa file:///path/to/keyfile
330 .Fl o Sy keylocation Ns = Ns Sy prompt
331 may not be specified here, since the standard input
332 is already being utilized for the send stream.
333 Once the receive has completed, you can use
335 to change this setting after the fact.
336 Similarly, you can receive a dataset as an encrypted child by specifying
338 to force the property to be inherited.
339 Overriding encryption properties (except for
341 is not possible with raw send streams.
343 If the receive is interrupted, save the partially received state, rather
345 Interruption may be due to premature termination of the stream
346 .Po e.g. due to network failure or failure of the remote system
347 if the stream is being read over a network connection
349 a checksum error in the stream, termination of the
351 process, or unclean shutdown of the system.
353 The receive can be resumed with a stream generated by
354 .Nm zfs Cm send Fl t Ar token ,
358 .Sy receive_resume_token
359 property of the filesystem or volume which is received into.
361 To use this flag, the storage pool must have the
362 .Sy extensible_dataset
366 for details on ZFS feature flags.
368 File system that is associated with the received stream is not mounted.
370 Print verbose information about the stream and the time required to perform the
373 Ensures that the effective value of the specified property after the
374 receive is unaffected by the value of that property in the send stream (if any),
375 as if the property had been excluded from the send stream.
377 If the specified property is not present in the send stream, this option does
380 If a received property needs to be overridden, the effective value will be
381 set or inherited, depending on whether the property is inheritable or not.
383 In the case of an incremental update,
385 leaves any existing local setting or explicit inheritance unchanged.
389 restrictions (e.g. set-once) apply equally to
396 .Ar filesystem Ns | Ns Ar volume
399 .Nm zfs Cm receive Fl s ,
400 deleting its saved partially received state.
406 .Ar filesystem Ns | Ns Ar snapshot
408 Attempt to repair data corruption in the specified dataset,
409 by using the provided stream as the source of healthy data.
410 This method of healing can only heal data blocks present in the stream.
411 Metadata can not be healed by corrective receive.
412 Running a scrub is recommended post-healing to ensure all data corruption was
415 It's important to consider why corruption has happened in the first place.
416 If you have slowly failing hardware - periodically repairing the data
417 is not going to save you from data loss later on when the hardware fails
422 .\" These are, respectively, examples 12, 13 from zfs.8
423 .\" Make sure to update them bidirectionally
424 .Ss Example 1 : No Remotely Replicating ZFS Data
425 The following commands send a full stream and then an incremental stream to a
426 remote machine, restoring them into
427 .Em poolB/received/fs@a
429 .Em poolB/received/fs@b ,
432 must contain the file system
434 and must not initially contain
435 .Em poolB/received/fs .
436 .Bd -literal -compact -offset Ds
437 .No # Nm zfs Cm send Ar pool/fs@a |
438 .No " " Nm ssh Ar host Nm zfs Cm receive Ar poolB/received/fs Ns @ Ns Ar a
439 .No # Nm zfs Cm send Fl i Ar a pool/fs@b |
440 .No " " Nm ssh Ar host Nm zfs Cm receive Ar poolB/received/fs
443 .Ss Example 2 : No Using the Nm zfs Cm receive Fl d No Option
444 The following command sends a full stream of
445 .Ar poolA/fsA/fsB@snap
446 to a remote machine, receiving it into
447 .Ar poolB/received/fsA/fsB@snap .
450 portion of the received snapshot's name is determined from the name of the sent
453 must contain the file system
456 .Ar poolB/received/fsA
457 does not exist, it is created as an empty file system.
458 .Bd -literal -compact -offset Ds
459 .No # Nm zfs Cm send Ar poolA/fsA/fsB@snap |
460 .No " " Nm ssh Ar host Nm zfs Cm receive Fl d Ar poolB/received