Initialize all fields in zfs_log_xvattr()
[zfs.git] / man / man8 / zfs-send.8
blob688bd033979afcd6077ac5e4a88f11b1f9985bb1
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 .\" 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.
31 .\"
32 .Dd April 15, 2021
33 .Dt ZFS-SEND 8
34 .Os
36 .Sh NAME
37 .Nm zfs-send
38 .Nd generate backup stream of ZFS dataset
39 .Sh SYNOPSIS
40 .Nm zfs
41 .Cm send
42 .Op Fl DLPRbcehnpsvw
43 .Op Oo Fl I Ns | Ns Fl i Oc Ar snapshot
44 .Ar snapshot
45 .Nm zfs
46 .Cm send
47 .Op Fl DLPcensvw
48 .Op Fl i Ar snapshot Ns | Ns Ar bookmark
49 .Ar filesystem Ns | Ns Ar volume Ns | Ns Ar snapshot
50 .Nm zfs
51 .Cm send
52 .Fl -redact Ar redaction_bookmark
53 .Op Fl DLPcenpv
54 .Op Fl i Ar snapshot Ns | Ns Ar bookmark
55 .Ar snapshot
56 .Nm zfs
57 .Cm send
58 .Op Fl Penv
59 .Fl t
60 .Ar receive_resume_token
61 .Nm zfs
62 .Cm send
63 .Op Fl Pnv
64 .Fl S Ar filesystem
65 .Nm zfs
66 .Cm redact
67 .Ar snapshot redaction_bookmark
68 .Ar redaction_snapshot Ns …
70 .Sh DESCRIPTION
71 .Bl -tag -width ""
72 .It Xo
73 .Nm zfs
74 .Cm send
75 .Op Fl DLPRbcehnpvw
76 .Op Oo Fl I Ns | Ns Fl i Oc Ar snapshot
77 .Ar snapshot
78 .Xc
79 Creates a stream representation of the second
80 .Ar snapshot ,
81 which is written to standard output.
82 The output can be redirected to a file or to a different system
83 .Po for example, using
84 .Xr ssh 1
85 .Pc .
86 By default, a full stream is generated.
87 .Bl -tag -width "-D"
88 .It Fl D , -dedup
89 Deduplicated send is no longer supported.
90 This flag is accepted for backwards compatibility, but a regular,
91 non-deduplicated stream will be generated.
92 .It Fl I Ar snapshot
93 Generate a stream package that sends all intermediary snapshots from the first
94 snapshot to the second snapshot.
95 For example,
96 .Fl I Em @a Em fs@d
97 is similar to
98 .Fl i Em @a Em fs@b Ns \&; Fl i Em @b Em fs@c Ns \&; Fl i Em @c Em fs@d .
99 The incremental source may be specified as with the
100 .Fl i
101 option.
102 .It Fl L , -large-block
103 Generate a stream which may contain blocks larger than 128KB.
104 This flag has no effect if the
105 .Sy large_blocks
106 pool feature is disabled, or if the
107 .Sy recordsize
108 property of this filesystem has never been set above 128KB.
109 The receiving system must have the
110 .Sy large_blocks
111 pool feature enabled as well.
113 .Xr zpool-features 7
114 for details on ZFS feature flags and the
115 .Sy large_blocks
116 feature.
117 .It Fl P , -parsable
118 Print machine-parsable verbose information about the stream package generated.
119 .It Fl R , -replicate
120 Generate a replication stream package, which will replicate the specified
121 file system, and all descendent file systems, up to the named snapshot.
122 When received, all properties, snapshots, descendent file systems, and clones
123 are preserved.
125 If the
126 .Fl i
128 .Fl I
129 flags are used in conjunction with the
130 .Fl R
131 flag, an incremental replication stream is generated.
132 The current values of properties, and current snapshot and file system names are
133 set when the stream is received.
134 If the
135 .Fl F
136 flag is specified when this stream is received, snapshots and file systems that
137 do not exist on the sending side are destroyed.
138 If the
139 .Fl R
140 flag is used to send encrypted datasets, then
141 .Fl w
142 must also be specified.
143 .It Fl e , -embed
144 Generate a more compact stream by using
145 .Sy WRITE_EMBEDDED
146 records for blocks which are stored more compactly on disk by the
147 .Sy embedded_data
148 pool feature.
149 This flag has no effect if the
150 .Sy embedded_data
151 feature is disabled.
152 The receiving system must have the
153 .Sy embedded_data
154 feature enabled.
155 If the
156 .Sy lz4_compress
157 feature is active on the sending system, then the receiving system must have
158 that feature enabled as well.
159 Datasets that are sent with this flag may not be
160 received as an encrypted dataset, since encrypted datasets cannot use the
161 .Sy embedded_data
162 feature.
164 .Xr zpool-features 7
165 for details on ZFS feature flags and the
166 .Sy embedded_data
167 feature.
168 .It Fl b , -backup
169 Sends only received property values whether or not they are overridden by local
170 settings, but only if the dataset has ever been received.
171 Use this option when you want
172 .Nm zfs Cm receive
173 to restore received properties backed up on the sent dataset and to avoid
174 sending local settings that may have nothing to do with the source dataset,
175 but only with how the data is backed up.
176 .It Fl c , -compressed
177 Generate a more compact stream by using compressed WRITE records for blocks
178 which are compressed on disk and in memory
179 .Po see the
180 .Sy compression
181 property for details
182 .Pc .
183 If the
184 .Sy lz4_compress
185 feature is active on the sending system, then the receiving system must have
186 that feature enabled as well.
187 If the
188 .Sy large_blocks
189 feature is enabled on the sending system but the
190 .Fl L
191 option is not supplied in conjunction with
192 .Fl c ,
193 then the data will be decompressed before sending so it can be split into
194 smaller block sizes.
195 Streams sent with
196 .Fl c
197 will not have their data recompressed on the receiver side using
198 .Fl o Sy compress Ns = Ar value .
199 The data will stay compressed as it was from the sender.
200 The new compression property will be set for future data.
201 .It Fl w , -raw
202 For encrypted datasets, send data exactly as it exists on disk.
203 This allows backups to be taken even if encryption keys are not currently loaded.
204 The backup may then be received on an untrusted machine since that machine will
205 not have the encryption keys to read the protected data or alter it without
206 being detected.
207 Upon being received, the dataset will have the same encryption
208 keys as it did on the send side, although the
209 .Sy keylocation
210 property will be defaulted to
211 .Sy prompt
212 if not otherwise provided.
213 For unencrypted datasets, this flag will be equivalent to
214 .Fl Lec .
215 Note that if you do not use this flag for sending encrypted datasets, data will
216 be sent unencrypted and may be re-encrypted with a different encryption key on
217 the receiving system, which will disable the ability to do a raw send to that
218 system for incrementals.
219 .It Fl h , -holds
220 Generate a stream package that includes any snapshot holds (created with the
221 .Nm zfs Cm hold
222 command), and indicating to
223 .Nm zfs Cm receive
224 that the holds be applied to the dataset on the receiving system.
225 .It Fl i Ar snapshot
226 Generate an incremental stream from the first
227 .Ar snapshot
228 .Pq the incremental source
229 to the second
230 .Ar snapshot
231 .Pq the incremental target .
232 The incremental source can be specified as the last component of the snapshot
233 name
234 .Po the
235 .Sy @
236 character and following
238 and it is assumed to be from the same file system as the incremental target.
240 If the destination is a clone, the source may be the origin snapshot, which must
241 be fully specified
242 .Po for example,
243 .Em pool/fs@origin ,
244 not just
245 .Em @origin
246 .Pc .
247 .It Fl n , -dryrun
248 Do a dry-run
249 .Pq Qq No-op
250 send.
251 Do not generate any actual send data.
252 This is useful in conjunction with the
253 .Fl v
255 .Fl P
256 flags to determine what data will be sent.
257 In this case, the verbose output will be written to standard output
258 .Po contrast with a non-dry-run, where the stream is written to standard output
259 and the verbose output goes to standard error
260 .Pc .
261 .It Fl p , -props
262 Include the dataset's properties in the stream.
263 This flag is implicit when
264 .Fl R
265 is specified.
266 The receiving system must also support this feature.
267 Sends of encrypted datasets must use
268 .Fl w
269 when using this flag.
270 .It Fl s , -skip-missing
271 Allows sending a replication stream even when there are snapshots missing in the
272 hierarchy.
273 When a snapshot is missing, instead of throwing an error and aborting the send,
274 a warning is printed to the standard error stream and the dataset to which it belongs
275 and its descendents are skipped.
276 This flag can only be used in conjunction with
277 .Fl R .
278 .It Fl v , -verbose
279 Print verbose information about the stream package generated.
280 This information includes a per-second report of how much data has been sent.
282 The format of the stream is committed.
283 You will be able to receive your streams on future versions of ZFS.
285 .It Xo
286 .Nm zfs
287 .Cm send
288 .Op Fl DLPcenvw
289 .Op Fl i Ar snapshot Ns | Ns Ar bookmark
290 .Ar filesystem Ns | Ns Ar volume Ns | Ns Ar snapshot
292 Generate a send stream, which may be of a filesystem, and may be incremental
293 from a bookmark.
294 If the destination is a filesystem or volume, the pool must be read-only, or the
295 filesystem must not be mounted.
296 When the stream generated from a filesystem or volume is received, the default
297 snapshot name will be
298 .Qq --head-- .
299 .Bl -tag -width "-D"
300 .It Fl D , -dedup
301 Deduplicated send is no longer supported.
302 This flag is accepted for backwards compatibility, but a regular,
303 non-deduplicated stream will be generated.
304 .It Fl L , -large-block
305 Generate a stream which may contain blocks larger than 128KB.
306 This flag has no effect if the
307 .Sy large_blocks
308 pool feature is disabled, or if the
309 .Sy recordsize
310 property of this filesystem has never been set above 128KB.
311 The receiving system must have the
312 .Sy large_blocks
313 pool feature enabled as well.
315 .Xr zpool-features 7
316 for details on ZFS feature flags and the
317 .Sy large_blocks
318 feature.
319 .It Fl P , -parsable
320 Print machine-parsable verbose information about the stream package generated.
321 .It Fl c , -compressed
322 Generate a more compact stream by using compressed WRITE records for blocks
323 which are compressed on disk and in memory
324 .Po see the
325 .Sy compression
326 property for details
327 .Pc .
328 If the
329 .Sy lz4_compress
330 feature is active on the sending system, then the receiving system must have
331 that feature enabled as well.
332 If the
333 .Sy large_blocks
334 feature is enabled on the sending system but the
335 .Fl L
336 option is not supplied in conjunction with
337 .Fl c ,
338 then the data will be decompressed before sending so it can be split into
339 smaller block sizes.
340 .It Fl w , -raw
341 For encrypted datasets, send data exactly as it exists on disk.
342 This allows backups to be taken even if encryption keys are not currently loaded.
343 The backup may then be received on an untrusted machine since that machine will
344 not have the encryption keys to read the protected data or alter it without
345 being detected.
346 Upon being received, the dataset will have the same encryption
347 keys as it did on the send side, although the
348 .Sy keylocation
349 property will be defaulted to
350 .Sy prompt
351 if not otherwise provided.
352 For unencrypted datasets, this flag will be equivalent to
353 .Fl Lec .
354 Note that if you do not use this flag for sending encrypted datasets, data will
355 be sent unencrypted and may be re-encrypted with a different encryption key on
356 the receiving system, which will disable the ability to do a raw send to that
357 system for incrementals.
358 .It Fl e , -embed
359 Generate a more compact stream by using
360 .Sy WRITE_EMBEDDED
361 records for blocks which are stored more compactly on disk by the
362 .Sy embedded_data
363 pool feature.
364 This flag has no effect if the
365 .Sy embedded_data
366 feature is disabled.
367 The receiving system must have the
368 .Sy embedded_data
369 feature enabled.
370 If the
371 .Sy lz4_compress
372 feature is active on the sending system, then the receiving system must have
373 that feature enabled as well.
374 Datasets that are sent with this flag may not be received as an encrypted dataset,
375 since encrypted datasets cannot use the
376 .Sy embedded_data
377 feature.
379 .Xr zpool-features 7
380 for details on ZFS feature flags and the
381 .Sy embedded_data
382 feature.
383 .It Fl i Ar snapshot Ns | Ns Ar bookmark
384 Generate an incremental send stream.
385 The incremental source must be an earlier snapshot in the destination's history.
386 It will commonly be an earlier snapshot in the destination's file system, in
387 which case it can be specified as the last component of the name
388 .Po the
389 .Sy #
391 .Sy @
392 character and following
393 .Pc .
395 If the incremental target is a clone, the incremental source can be the origin
396 snapshot, or an earlier snapshot in the origin's filesystem, or the origin's
397 origin, etc.
398 .It Fl n , -dryrun
399 Do a dry-run
400 .Pq Qq No-op
401 send.
402 Do not generate any actual send data.
403 This is useful in conjunction with the
404 .Fl v
406 .Fl P
407 flags to determine what data will be sent.
408 In this case, the verbose output will be written to standard output
409 .Po contrast with a non-dry-run, where the stream is written to standard output
410 and the verbose output goes to standard error
411 .Pc .
412 .It Fl v , -verbose
413 Print verbose information about the stream package generated.
414 This information includes a per-second report of how much data has been sent.
416 .It Xo
417 .Nm zfs
418 .Cm send
419 .Fl -redact Ar redaction_bookmark
420 .Op Fl DLPcenpv
421 .Op Fl i Ar snapshot Ns | Ns Ar bookmark
422 .Ar snapshot
424 Generate a redacted send stream.
425 This send stream contains all blocks from the snapshot being sent that aren't
426 included in the redaction list contained in the bookmark specified by the
427 .Fl -redact
429 .Fl d )
430 flag.
431 The resulting send stream is said to be redacted with respect to the snapshots
432 the bookmark specified by the
433 .Fl -redact No flag was created with.
434 The bookmark must have been created by running
435 .Nm zfs Cm redact
436 on the snapshot being sent.
438 This feature can be used to allow clones of a filesystem to be made available on
439 a remote system, in the case where their parent need not (or needs to not) be
440 usable.
441 For example, if a filesystem contains sensitive data, and it has clones where
442 that sensitive data has been secured or replaced with dummy data, redacted sends
443 can be used to replicate the secured data without replicating the original
444 sensitive data, while still sharing all possible blocks.
445 A snapshot that has been redacted with respect to a set of snapshots will
446 contain all blocks referenced by at least one snapshot in the set, but will
447 contain none of the blocks referenced by none of the snapshots in the set.
448 In other words, if all snapshots in the set have modified a given block in the
449 parent, that block will not be sent; but if one or more snapshots have not
450 modified a block in the parent, they will still reference the parent's block, so
451 that block will be sent.
452 Note that only user data will be redacted.
454 When the redacted send stream is received, we will generate a redacted
455 snapshot.
456 Due to the nature of redaction, a redacted dataset can only be used in the
457 following ways:
458 .Bl -enum -width "a."
460 To receive, as a clone, an incremental send from the original snapshot to one
461 of the snapshots it was redacted with respect to.
462 In this case, the stream will produce a valid dataset when received because all
463 blocks that were redacted in the parent are guaranteed to be present in the
464 child's send stream.
465 This use case will produce a normal snapshot, which can be used just like other
466 snapshots.
469 To receive an incremental send from the original snapshot to something
470 redacted with respect to a subset of the set of snapshots the initial snapshot
471 was redacted with respect to.
472 In this case, each block that was redacted in the original is still redacted
473 (redacting with respect to additional snapshots causes less data to be redacted
474 (because the snapshots define what is permitted, and everything else is
475 redacted)).
476 This use case will produce a new redacted snapshot.
478 To receive an incremental send from a redaction bookmark of the original
479 snapshot that was created when redacting with respect to a subset of the set of
480 snapshots the initial snapshot was created with respect to
481 anything else.
482 A send stream from such a redaction bookmark will contain all of the blocks
483 necessary to fill in any redacted data, should it be needed, because the sending
484 system is aware of what blocks were originally redacted.
485 This will either produce a normal snapshot or a redacted one, depending on
486 whether the new send stream is redacted.
488 To receive an incremental send from a redacted version of the initial
489 snapshot that is redacted with respect to a subject of the set of snapshots the
490 initial snapshot was created with respect to.
491 A send stream from a compatible redacted dataset will contain all of the blocks
492 necessary to fill in any redacted data.
493 This will either produce a normal snapshot or a redacted one, depending on
494 whether the new send stream is redacted.
496 To receive a full send as a clone of the redacted snapshot.
497 Since the stream is a full send, it definitionally contains all the data needed
498 to create a new dataset.
499 This use case will either produce a normal snapshot or a redacted one, depending
500 on whether the full send stream was redacted.
503 These restrictions are detected and enforced by
504 .Nm zfs Cm receive ;
505 a redacted send stream will contain the list of snapshots that the stream is
506 redacted with respect to.
507 These are stored with the redacted snapshot, and are used to detect and
508 correctly handle the cases above.
509 Note that for technical reasons,
510 raw sends and redacted sends cannot be combined at this time.
511 .It Xo
512 .Nm zfs
513 .Cm send
514 .Op Fl Penv
515 .Fl t
516 .Ar receive_resume_token
518 Creates a send stream which resumes an interrupted receive.
520 .Ar receive_resume_token
521 is the value of this property on the filesystem or volume that was being
522 received into.
523 See the documentation for
524 .Nm zfs Cm receive Fl s
525 for more details.
526 .It Xo
527 .Nm zfs
528 .Cm send
529 .Op Fl Pnv
530 .Op Fl i Ar snapshot Ns | Ns Ar bookmark
531 .Fl S
532 .Ar filesystem
534 Generate a send stream from a dataset that has been partially received.
535 .Bl -tag -width "-L"
536 .It Fl S , -saved
537 This flag requires that the specified filesystem previously received a resumable
538 send that did not finish and was interrupted.
539 In such scenarios this flag
540 enables the user to send this partially received state.
541 Using this flag will always use the last fully received snapshot
542 as the incremental source if it exists.
544 .It Xo
545 .Nm zfs
546 .Cm redact
547 .Ar snapshot redaction_bookmark
548 .Ar redaction_snapshot Ns …
550 Generate a new redaction bookmark.
551 In addition to the typical bookmark information, a redaction bookmark contains
552 the list of redacted blocks and the list of redaction snapshots specified.
553 The redacted blocks are blocks in the snapshot which are not referenced by any
554 of the redaction snapshots.
555 These blocks are found by iterating over the metadata in each redaction snapshot
556 to determine what has been changed since the target snapshot.
557 Redaction is designed to support redacted zfs sends; see the entry for
558 .Nm zfs Cm send
559 for more information on the purpose of this operation.
560 If a redact operation fails partway through (due to an error or a system
561 failure), the redaction can be resumed by rerunning the same command.
563 .Ss Redaction
564 ZFS has support for a limited version of data subsetting, in the form of
565 redaction.
566 Using the
567 .Nm zfs Cm redact
568 command, a
569 .Sy redaction bookmark
570 can be created that stores a list of blocks containing sensitive information.
571 When provided to
572 .Nm zfs Cm send ,
573 this causes a
574 .Sy redacted send
575 to occur.
576 Redacted sends omit the blocks containing sensitive information,
577 replacing them with REDACT records.
578 When these send streams are received, a
579 .Sy redacted dataset
580 is created.
581 A redacted dataset cannot be mounted by default, since it is incomplete.
582 It can be used to receive other send streams.
583 In this way datasets can be used for data backup and replication,
584 with all the benefits that zfs send and receive have to offer,
585 while protecting sensitive information from being
586 stored on less-trusted machines or services.
588 For the purposes of redaction, there are two steps to the process.
589 A redact step, and a send/receive step.
590 First, a redaction bookmark is created.
591 This is done by providing the
592 .Nm zfs Cm redact
593 command with a parent snapshot, a bookmark to be created, and a number of
594 redaction snapshots.
595 These redaction snapshots must be descendants of the parent snapshot,
596 and they should modify data that is considered sensitive in some way.
597 Any blocks of data modified by all of the redaction snapshots will
598 be listed in the redaction bookmark, because it represents the truly sensitive
599 information.
600 When it comes to the send step, the send process will not send
601 the blocks listed in the redaction bookmark, instead replacing them with
602 REDACT records.
603 When received on the target system, this will create a
604 redacted dataset, missing the data that corresponds to the blocks in the
605 redaction bookmark on the sending system.
606 The incremental send streams from
607 the original parent to the redaction snapshots can then also be received on
608 the target system, and this will produce a complete snapshot that can be used
609 normally.
610 Incrementals from one snapshot on the parent filesystem and another
611 can also be done by sending from the redaction bookmark, rather than the
612 snapshots themselves.
614 In order to make the purpose of the feature more clear, an example is provided.
615 Consider a zfs filesystem containing four files.
616 These files represent information for an online shopping service.
617 One file contains a list of usernames and passwords, another contains purchase histories,
618 a third contains click tracking data, and a fourth contains user preferences.
619 The owner of this data wants to make it available for their development teams to
620 test against, and their market research teams to do analysis on.
621 The development teams need information about user preferences and the click
622 tracking data, while the market research teams need information about purchase
623 histories and user preferences.
624 Neither needs access to the usernames and passwords.
625 However, because all of this data is stored in one ZFS filesystem,
626 it must all be sent and received together.
627 In addition, the owner of the data
628 wants to take advantage of features like compression, checksumming, and
629 snapshots, so they do want to continue to use ZFS to store and transmit their data.
630 Redaction can help them do so.
631 First, they would make two clones of a snapshot of the data on the source.
632 In one clone, they create the setup they want their market research team to see;
633 they delete the usernames and passwords file,
634 and overwrite the click tracking data with dummy information.
635 In another, they create the setup they want the development teams
636 to see, by replacing the passwords with fake information and replacing the
637 purchase histories with randomly generated ones.
638 They would then create a redaction bookmark on the parent snapshot,
639 using snapshots on the two clones as redaction snapshots.
640 The parent can then be sent, redacted, to the target
641 server where the research and development teams have access.
642 Finally, incremental sends from the parent snapshot to each of the clones can be sent
643 to and received on the target server; these snapshots are identical to the
644 ones on the source, and are ready to be used, while the parent snapshot on the
645 target contains none of the username and password data present on the source,
646 because it was removed by the redacted send operation.
648 .Sh SEE ALSO
649 .Xr zfs-bookmark 8 ,
650 .Xr zfs-receive 8 ,
651 .Xr zfs-redact 8 ,
652 .Xr zfs-snapshot 8