zfs: merge OpenZFS master-9305ff2ed
[freebsd.git] / sys / contrib / openzfs / man / man8 / zfs-receive.8
1 .\"
2 .\" CDDL HEADER START
3 .\"
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.
7 .\"
8 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 .\" or http://www.opensolaris.org/os/licensing.
10 .\" See the License for the specific language governing permissions
11 .\" and limitations under the License.
12 .\"
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]
18 .\"
19 .\" CDDL HEADER END
20 .\"
21 .\"
22 .\" Copyright (c) 2009 Sun Microsystems, Inc. All Rights Reserved.
23 .\" Copyright 2011 Joshua M. Clulow <josh@sysmgr.org>
24 .\" Copyright (c) 2011, 2019 by Delphix. All rights reserved.
25 .\" Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
26 .\" Copyright (c) 2014, Joyent, Inc. All rights reserved.
27 .\" Copyright (c) 2014 by Adam Stevko. All rights reserved.
28 .\" Copyright (c) 2014 Integros [integros.com]
29 .\" Copyright 2019 Richard Laager. All rights reserved.
30 .\" Copyright 2018 Nexenta Systems, Inc.
31 .\" Copyright 2019 Joyent, Inc.
32 .\"
33 .Dd February 16, 2020
34 .Dt ZFS-RECEIVE 8
35 .Os
36 .Sh NAME
37 .Nm zfs-receive
38 .Nd Creates a snapshot whose contents are as specified in the stream provided on standard input.
39 .Sh SYNOPSIS
40 .Nm zfs
41 .Cm receive
42 .Op Fl FhMnsuv
43 .Op Fl o Sy origin Ns = Ns Ar snapshot
44 .Op Fl o Ar property Ns = Ns Ar value
45 .Op Fl x Ar property
46 .Ar filesystem Ns | Ns Ar volume Ns | Ns Ar snapshot
47 .Nm zfs
48 .Cm receive
49 .Op Fl FhMnsuv
50 .Op Fl d Ns | Ns Fl e
51 .Op Fl o Sy origin Ns = Ns Ar snapshot
52 .Op Fl o Ar property Ns = Ns Ar value
53 .Op Fl x Ar property
54 .Ar filesystem
55 .Nm zfs
56 .Cm receive
57 .Fl A
58 .Ar filesystem Ns | Ns Ar volume
59 .Sh DESCRIPTION
60 .Bl -tag -width ""
61 .It Xo
62 .Nm zfs
63 .Cm receive
64 .Op Fl FhMnsuv
65 .Op Fl o Sy origin Ns = Ns Ar snapshot
66 .Op Fl o Ar property Ns = Ns Ar value
67 .Op Fl x Ar property
68 .Ar filesystem Ns | Ns Ar volume Ns | Ns Ar snapshot
69 .Xc
70 .It Xo
71 .Nm zfs
72 .Cm receive
73 .Op Fl FhMnsuv
74 .Op Fl d Ns | Ns Fl e
75 .Op Fl o Sy origin Ns = Ns Ar snapshot
76 .Op Fl o Ar property Ns = Ns Ar value
77 .Op Fl x Ar property
78 .Ar filesystem
79 .Xc
80 Creates a snapshot whose contents are as specified in the stream provided on
81 standard input.
82 If a full stream is received, then a new file system is created as well.
83 Streams are created using the
84 .Nm zfs Cm send
85 subcommand, which by default creates a full stream.
86 .Nm zfs Cm recv
87 can be used as an alias for
88 .Nm zfs Cm receive.
89 .Pp
90 If an incremental stream is received, then the destination file system must
91 already exist, and its most recent snapshot must match the incremental stream's
92 source.
93 For
94 .Sy zvols ,
95 the destination device link is destroyed and recreated, which means the
96 .Sy zvol
97 cannot be accessed during the
98 .Cm receive
99 operation.
100 .Pp
101 When a snapshot replication package stream that is generated by using the
102 .Nm zfs Cm send Fl R
103 command is received, any snapshots that do not exist on the sending location are
104 destroyed by using the
105 .Nm zfs Cm destroy Fl d
106 command.
107 .Pp
108 The ability to send and receive deduplicated send streams has been removed.
109 However, a deduplicated send stream created with older software can be converted
110 to a regular (non-deduplicated) stream by using the
111 .Nm zstream Cm redup
112 command.
113 .Pp
114 If
115 .Fl o Em property Ns = Ns Ar value
116 or
117 .Fl x Em property
118 is specified, it applies to the effective value of the property throughout
119 the entire subtree of replicated datasets. Effective property values will be
120 set (
121 .Fl o
122 ) or inherited (
123 .Fl x
124 ) on the topmost in the replicated subtree. In descendant datasets, if the
125 property is set by the send stream, it will be overridden by forcing the
126 property to be inherited from the top‐most file system. Received properties
127 are retained in spite of being overridden and may be restored with
128 .Nm zfs Cm inherit Fl S .
129 Specifying
130 .Fl o Sy origin Ns = Ns Em snapshot
131 is a special case because, even if
132 .Sy origin
133 is a read-only property and cannot be set, it's allowed to receive the send
134 stream as a clone of the given snapshot.
135 .Pp
136 Raw encrypted send streams (created with
137 .Nm zfs Cm send Fl w
138 ) may only be received as is, and cannot be re-encrypted, decrypted, or
139 recompressed by the receive process. Unencrypted streams can be received as
140 encrypted datasets, either through inheritance or by specifying encryption
141 parameters with the
142 .Fl o
143 options. Note that the
144 .Sy keylocation
145 property cannot be overridden to
146 .Sy prompt
147 during a receive. This is because the receive process itself is already using
148 stdin for the send stream. Instead, the property can be overridden after the
149 receive completes.
150 .Pp
151 The added security provided by raw sends adds some restrictions to the send
152 and receive process. ZFS will not allow a mix of raw receives and non-raw
153 receives. Specifically, any raw incremental receives that are attempted after
154 a non-raw receive will fail. Non-raw receives do not have this restriction and,
155 therefore, are always possible. Because of this, it is best practice to always
156 use either raw sends for their security benefits or non-raw sends for their
157 flexibility when working with encrypted datasets, but not a combination.
158 .Pp
159 The reason for this restriction stems from the inherent restrictions of the
160 AEAD ciphers that ZFS uses to encrypt data. When using ZFS native encryption,
161 each block of data is encrypted against a randomly generated number known as
162 the "initialization vector" (IV), which is stored in the filesystem metadata.
163 This number is required by the encryption algorithms whenever the data is to
164 be decrypted. Together, all of the IVs provided for all of the blocks in a
165 given snapshot are collectively called an "IV set". When ZFS performs a raw
166 send, the IV set is transferred from the source to the destination in the send
167 stream. When ZFS performs a non-raw send, the data is decrypted by the source
168 system and re-encrypted by the destination system, creating a snapshot with
169 effectively the same data, but a different IV set. In order for decryption to
170 work after a raw send, ZFS must ensure that the IV set used on both the source
171 and destination side match. When an incremental raw receive is performed on
172 top of an existing snapshot, ZFS will check to confirm that the "from"
173 snapshot on both the source and destination were using the same IV set,
174 ensuring the new IV set is consistent.
175 .Pp
176 The name of the snapshot
177 .Pq and file system, if a full stream is received
178 that this subcommand creates depends on the argument type and the use of the
179 .Fl d
180 or
181 .Fl e
182 options.
183 .Pp
184 If the argument is a snapshot name, the specified
185 .Ar snapshot
186 is created.
187 If the argument is a file system or volume name, a snapshot with the same name
188 as the sent snapshot is created within the specified
189 .Ar filesystem
190 or
191 .Ar volume .
192 If neither of the
193 .Fl d
194 or
195 .Fl e
196 options are specified, the provided target snapshot name is used exactly as
197 provided.
198 .Pp
199 The
200 .Fl d
201 and
202 .Fl e
203 options cause the file system name of the target snapshot to be determined by
204 appending a portion of the sent snapshot's name to the specified target
205 .Ar filesystem .
206 If the
207 .Fl d
208 option is specified, all but the first element of the sent snapshot's file
209 system path
210 .Pq usually the pool name
211 is used and any required intermediate file systems within the specified one are
212 created.
213 If the
214 .Fl e
215 option is specified, then only the last element of the sent snapshot's file
216 system name
217 .Pq i.e. the name of the source file system itself
218 is used as the target file system name.
219 .Bl -tag -width "-F"
220 .It Fl F
221 Force a rollback of the file system to the most recent snapshot before
222 performing the receive operation.
223 If receiving an incremental replication stream
224 .Po for example, one generated by
225 .Nm zfs Cm send Fl R Op Fl i Ns | Ns Fl I
226 .Pc ,
227 destroy snapshots and file systems that do not exist on the sending side.
228 .It Fl d
229 Discard the first element of the sent snapshot's file system name, using the
230 remaining elements to determine the name of the target file system for the new
231 snapshot as described in the paragraph above.
232 .It Fl e
233 Discard all but the last element of the sent snapshot's file system name, using
234 that element to determine the name of the target file system for the new
235 snapshot as described in the paragraph above.
236 .It Fl h
237 Skip the receive of holds.  There is no effect if holds are not sent.
238 .It Fl M
239 Force an unmount of the file system while receiving a snapshot.
240 This option is not supported on Linux.
241 .It Fl n
242 Do not actually receive the stream.
243 This can be useful in conjunction with the
244 .Fl v
245 option to verify the name the receive operation would use.
246 .It Fl o Sy origin Ns = Ns Ar snapshot
247 Forces the stream to be received as a clone of the given snapshot.
248 If the stream is a full send stream, this will create the filesystem
249 described by the stream as a clone of the specified snapshot.
250 Which snapshot was specified will not affect the success or failure of the
251 receive, as long as the snapshot does exist.
252 If the stream is an incremental send stream, all the normal verification will be
253 performed.
254 .It Fl o Em property Ns = Ns Ar value
255 Sets the specified property as if the command
256 .Nm zfs Cm set Em property Ns = Ns Ar value
257 was invoked immediately before the receive. When receiving a stream from
258 .Nm zfs Cm send Fl R ,
259 causes the property to be inherited by all descendant datasets, as through
260 .Nm zfs Cm inherit Em property
261 was run on any descendant datasets that have this property set on the
262 sending system.
263 .Pp
264 If the send stream was sent with
265 .Fl c
266 then overriding the
267 .Sy compression
268 property will have no affect on received data but the
269 .Sy compression
270 property will be set. To have the data recompressed on receive remove the
271 .Fl c
272 flag from the send stream.
273 .Pp
274 Any editable property can be set at receive time. Set-once properties bound
275 to the received data, such as
276 .Sy normalization
277 and
278 .Sy casesensitivity ,
279 cannot be set at receive time even when the datasets are newly created by
280 .Nm zfs Cm receive .
281 Additionally both settable properties
282 .Sy version
283 and
284 .Sy volsize
285 cannot be set at receive time.
286 .Pp
287 The
288 .Fl o
289 option may be specified multiple times, for different properties. An error
290 results if the same property is specified in multiple
291 .Fl o
292 or
293 .Fl x
294 options.
295 .Pp
296 The
297 .Fl o
298 option may also be used to override encryption properties upon initial
299 receive. This allows unencrypted streams to be received as encrypted datasets.
300 To cause the received dataset (or root dataset of a recursive stream) to be
301 received as an encryption root, specify encryption properties in the same
302 manner as is required for
303 .Nm zfs
304 .Cm create .
305 For instance:
306 .Bd -literal
307 # zfs send tank/test@snap1 | zfs recv -o encryption=on -o keyformat=passphrase -o keylocation=file:///path/to/keyfile
308 .Ed
309 .Pp
310 Note that
311 .Op Fl o Ar keylocation Ns = Ns Ar prompt
312 may not be specified here, since stdin is already being utilized for the send
313 stream. Once the receive has completed, you can use
314 .Nm zfs
315 .Cm set
316 to change this setting after the fact. Similarly, you can receive a dataset as
317 an encrypted child by specifying
318 .Op Fl x Ar encryption
319 to force the property to be inherited. Overriding encryption properties (except
320 for
321 .Sy keylocation Ns )
322 is not possible with raw send streams.
323 .It Fl s
324 If the receive is interrupted, save the partially received state, rather
325 than deleting it.
326 Interruption may be due to premature termination of the stream
327 .Po e.g. due to network failure or failure of the remote system
328 if the stream is being read over a network connection
329 .Pc ,
330 a checksum error in the stream, termination of the
331 .Nm zfs Cm receive
332 process, or unclean shutdown of the system.
333 .Pp
334 The receive can be resumed with a stream generated by
335 .Nm zfs Cm send Fl t Ar token ,
336 where the
337 .Ar token
338 is the value of the
339 .Sy receive_resume_token
340 property of the filesystem or volume which is received into.
341 .Pp
342 To use this flag, the storage pool must have the
343 .Sy extensible_dataset
344 feature enabled.
345 See
346 .Xr zpool-features 5
347 for details on ZFS feature flags.
348 .It Fl u
349 File system that is associated with the received stream is not mounted.
350 .It Fl v
351 Print verbose information about the stream and the time required to perform the
352 receive operation.
353 .It Fl x Em property
354 Ensures that the effective value of the specified property after the
355 receive is unaffected by the value of that property in the send stream (if any),
356 as if the property had been excluded from the send stream.
357 .Pp
358 If the specified property is not present in the send stream, this option does
359 nothing.
360 .Pp
361 If a received property needs to be overridden, the effective value will be
362 set or inherited, depending on whether the property is inheritable or not.
363 .Pp
364 In the case of an incremental update,
365 .Fl x
366 leaves any existing local setting or explicit inheritance unchanged.
367 .Pp
368 All
369 .Fl o
370 restrictions (e.g. set-once) apply equally to
371 .Fl x .
372 .El
373 .It Xo
374 .Nm zfs
375 .Cm receive
376 .Fl A
377 .Ar filesystem Ns | Ns Ar volume
378 .Xc
379 Abort an interrupted
380 .Nm zfs Cm receive Fl s ,
381 deleting its saved partially received state.
382 .El
383 .Sh SEE ALSO
384 .Xr zfs-send 8
385 .Xr zstream 8