~akopytov/percona-xtrabackup/bug1166888-2.1

« back to all changes in this revision

Viewing changes to src/libarchive/tar/bsdtar.1

  • Committer: Alexey Kopytov
  • Date: 2012-02-10 20:05:56 UTC
  • mto: (391.1.5 staging)
  • mto: This revision was merged to the branch mainline in revision 390.
  • Revision ID: akopytov@gmail.com-20120210200556-6kx41z8wwrqfucro
Rebase of the parallel compression patch on new trunk + post-review
fixes.

Implementation of parallel compression and streaming for XtraBackup.

This revision implements the following changes:

* InnoDB files are now streamed by the xtrabackup binary rather than
innobackupex. As a result, integrity is now verified by xtrabackup and
thus tar4ibd is no longer needed, so it was removed.

* xtrabackup binary now accepts the new '--stream' option which has
exactly the same semantics as the '--stream' option in
innobackupex: it tells xtrabackup to stream all files to the standard
output in the specified format rather than storing them locally.

* The xtrabackup binary can now do parallel compression using the
quicklz library. Two new options were added to xtrabackup to support
this feature:

- '--compress' tells xtrabackup to compress all output data, including
the transaction log file and meta data files, using the specified
compression algorithm. The only currently supported algorithm is
'quicklz'. The resulting files have the qpress archive format,
i.e. every *.qp file produced by xtrabackup is essentially a one-file
qpress archive and can be extracted and uncompressed by the qpress
file archiver (http://www.quicklz.com/).

- '--compress-threads' specifies the number of worker threads used by
xtrabackup for parallel data compression. This option defaults to 1.

Parallel compression ('--compress-threads') can be used together with
parallel file copying ('--parallel'). For example, '--parallel=4
--compress --compress-threads=2' will create 4 IO threads that will
read the data and pipe it to 2 compression threads.

* To support simultaneous compression and streaming, a new custom
streaming format called 'xbstream' was introduced to XtraBackup in
addition to the 'tar' format. That was required to overcome some
limitations of traditional archive formats such as 'tar', 'cpio' and
others that do not allow streaming dynamically generated files, for
example dynamically compressed files.  Other advantages of xbstream over
traditional streaming/archive formats include ability to stream multiple
files concurrently (so it is possible to use streaming in the xbstream
format together with the --parallel option) and more compact data
storage.

* To allow streaming and extracting files to/from the xbstream format
produced by xtrabackup, a new utility aptly called 'xbstream' was
added to the XtraBackup distribution. This utility has a tar-like
interface:

- with the '-x' option it extracts files from the stream read from its
standard input to the current directory unless specified otherwise
with the '-C' option.

- with the '-c' option it streams files specified on the command line
to its standard output.

The utility also tries to minimize its impact on the OS page cache by
using the appropriate posix_fadvise() calls when available.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
.\" Copyright (c) 2003-2007 Tim Kientzle
 
2
.\" All rights reserved.
 
3
.\"
 
4
.\" Redistribution and use in source and binary forms, with or without
 
5
.\" modification, are permitted provided that the following conditions
 
6
.\" are met:
 
7
.\" 1. Redistributions of source code must retain the above copyright
 
8
.\"    notice, this list of conditions and the following disclaimer.
 
9
.\" 2. Redistributions in binary form must reproduce the above copyright
 
10
.\"    notice, this list of conditions and the following disclaimer in the
 
11
.\"    documentation and/or other materials provided with the distribution.
 
12
.\"
 
13
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 
14
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 
15
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 
16
.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 
17
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 
18
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 
19
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 
20
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 
21
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 
22
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 
23
.\" SUCH DAMAGE.
 
24
.\"
 
25
.\" $FreeBSD: src/usr.bin/tar/bsdtar.1,v 1.46 2008/12/06 07:37:55 kientzle Exp $
 
26
.\"
 
27
.Dd Oct 12, 2009
 
28
.Dt BSDTAR 1
 
29
.Os
 
30
.Sh NAME
 
31
.Nm tar
 
32
.Nd manipulate tape archives
 
33
.Sh SYNOPSIS
 
34
.Nm
 
35
.Op Ar bundled-flags Ao args Ac
 
36
.Op Ao Ar file Ac | Ao Ar pattern Ac ...
 
37
.Nm
 
38
.Brq Fl c
 
39
.Op Ar options
 
40
.Op Ar files | Ar directories
 
41
.Nm
 
42
.Brq Fl r | Fl u
 
43
.Fl f Ar archive-file
 
44
.Op Ar options
 
45
.Op Ar files | Ar directories
 
46
.Nm
 
47
.Brq Fl t | Fl x
 
48
.Op Ar options
 
49
.Op Ar patterns
 
50
.Sh DESCRIPTION
 
51
.Nm
 
52
creates and manipulates streaming archive files.
 
53
This implementation can extract from tar, pax, cpio, zip, jar, ar,
 
54
and ISO 9660 cdrom images and can create tar, pax, cpio, ar,
 
55
and shar archives.
 
56
.Pp
 
57
The first synopsis form shows a
 
58
.Dq bundled
 
59
option word.
 
60
This usage is provided for compatibility with historical implementations.
 
61
See COMPATIBILITY below for details.
 
62
.Pp
 
63
The other synopsis forms show the preferred usage.
 
64
The first option to
 
65
.Nm
 
66
is a mode indicator from the following list:
 
67
.Bl -tag -compact -width indent
 
68
.It Fl c
 
69
Create a new archive containing the specified items.
 
70
.It Fl r
 
71
Like
 
72
.Fl c ,
 
73
but new entries are appended to the archive.
 
74
Note that this only works on uncompressed archives stored in regular files.
 
75
The
 
76
.Fl f
 
77
option is required.
 
78
.It Fl t
 
79
List archive contents to stdout.
 
80
.It Fl u
 
81
Like
 
82
.Fl r ,
 
83
but new entries are added only if they have a modification date
 
84
newer than the corresponding entry in the archive.
 
85
Note that this only works on uncompressed archives stored in regular files.
 
86
The
 
87
.Fl f
 
88
option is required.
 
89
.It Fl x
 
90
Extract to disk from the archive.
 
91
If a file with the same name appears more than once in the archive,
 
92
each copy will be extracted, with later copies overwriting (replacing)
 
93
earlier copies.
 
94
.El
 
95
.Pp
 
96
In
 
97
.Fl c ,
 
98
.Fl r ,
 
99
or
 
100
.Fl u
 
101
mode, each specified file or directory is added to the
 
102
archive in the order specified on the command line.
 
103
By default, the contents of each directory are also archived.
 
104
.Pp
 
105
In extract or list mode, the entire command line
 
106
is read and parsed before the archive is opened.
 
107
The pathnames or patterns on the command line indicate
 
108
which items in the archive should be processed.
 
109
Patterns are shell-style globbing patterns as
 
110
documented in
 
111
.Xr tcsh 1 .
 
112
.Sh OPTIONS
 
113
Unless specifically stated otherwise, options are applicable in
 
114
all operating modes.
 
115
.Bl -tag -width indent
 
116
.It Cm @ Ns Pa archive
 
117
(c and r mode only)
 
118
The specified archive is opened and the entries
 
119
in it will be appended to the current archive.
 
120
As a simple example,
 
121
.Dl Nm Fl c Fl f Pa - Pa newfile Cm @ Ns Pa original.tar
 
122
writes a new archive to standard output containing a file
 
123
.Pa newfile
 
124
and all of the entries from
 
125
.Pa original.tar .
 
126
In contrast,
 
127
.Dl Nm Fl c Fl f Pa - Pa newfile Pa original.tar
 
128
creates a new archive with only two entries.
 
129
Similarly,
 
130
.Dl Nm Fl czf Pa - Fl -format Cm pax Cm @ Ns Pa -
 
131
reads an archive from standard input (whose format will be determined
 
132
automatically) and converts it into a gzip-compressed
 
133
pax-format archive on stdout.
 
134
In this way,
 
135
.Nm
 
136
can be used to convert archives from one format to another.
 
137
.It Fl b Ar blocksize
 
138
Specify the block size, in 512-byte records, for tape drive I/O.
 
139
As a rule, this argument is only needed when reading from or writing
 
140
to tape drives, and usually not even then as the default block size of
 
141
20 records (10240 bytes) is very common.
 
142
.It Fl C Ar directory
 
143
In c and r mode, this changes the directory before adding
 
144
the following files.
 
145
In x mode, change directories after opening the archive
 
146
but before extracting entries from the archive.
 
147
.It Fl -check-links
 
148
(c and r modes only)
 
149
Issue a warning message unless all links to each file are archived.
 
150
.It Fl -chroot
 
151
(x mode only)
 
152
.Fn chroot
 
153
to the current directory after processing any
 
154
.Fl C
 
155
options and before extracting any files.
 
156
.It Fl -exclude Ar pattern
 
157
Do not process files or directories that match the
 
158
specified pattern.
 
159
Note that exclusions take precedence over patterns or filenames
 
160
specified on the command line.
 
161
.It Fl -format Ar format
 
162
(c, r, u mode only)
 
163
Use the specified format for the created archive.
 
164
Supported formats include
 
165
.Dq cpio ,
 
166
.Dq pax ,
 
167
.Dq shar ,
 
168
and
 
169
.Dq ustar .
 
170
Other formats may also be supported; see
 
171
.Xr libarchive-formats 5
 
172
for more information about currently-supported formats.
 
173
In r and u modes, when extending an existing archive, the format specified
 
174
here must be compatible with the format of the existing archive on disk.
 
175
.It Fl f Ar file
 
176
Read the archive from or write the archive to the specified file.
 
177
The filename can be
 
178
.Pa -
 
179
for standard input or standard output.
 
180
If not specified, the default tape device will be used.
 
181
(On
 
182
.Fx ,
 
183
the default tape device is
 
184
.Pa /dev/sa0 . )
 
185
.It Fl H
 
186
(c and r mode only)
 
187
Symbolic links named on the command line will be followed; the
 
188
target of the link will be archived, not the link itself.
 
189
.It Fl h
 
190
(c and r mode only)
 
191
Synonym for
 
192
.Fl L .
 
193
.It Fl I
 
194
Synonym for
 
195
.Fl T .
 
196
.It Fl -include Ar pattern
 
197
Process only files or directories that match the specified pattern.
 
198
Note that exclusions specified with
 
199
.Fl -exclude
 
200
take precedence over inclusions.
 
201
If no inclusions are explicitly specified, all entries are processed by
 
202
default.
 
203
The
 
204
.Fl -include
 
205
option is especially useful when filtering archives.
 
206
For example, the command
 
207
.Dl Nm Fl c Fl f Pa new.tar Fl -include='*foo*' Cm @ Ns Pa old.tgz
 
208
creates a new archive
 
209
.Pa new.tar
 
210
containing only the entries from
 
211
.Pa old.tgz
 
212
containing the string
 
213
.Sq foo .
 
214
.It Fl j
 
215
(c mode only)
 
216
Compress the resulting archive with
 
217
.Xr bzip2 1 .
 
218
In extract or list modes, this option is ignored.
 
219
Note that, unlike other
 
220
.Nm tar
 
221
implementations, this implementation recognizes bzip2 compression
 
222
automatically when reading archives.
 
223
.It Fl k
 
224
(x mode only)
 
225
Do not overwrite existing files.
 
226
In particular, if a file appears more than once in an archive,
 
227
later copies will not overwrite earlier copies.
 
228
.It Fl -keep-newer-files
 
229
(x mode only)
 
230
Do not overwrite existing files that are newer than the
 
231
versions appearing in the archive being extracted.
 
232
.It Fl L
 
233
(c and r mode only)
 
234
All symbolic links will be followed.
 
235
Normally, symbolic links are archived as such.
 
236
With this option, the target of the link will be archived instead.
 
237
.It Fl l
 
238
This is a synonym for the
 
239
.Fl -check-links
 
240
option.
 
241
.It Fl m
 
242
(x mode only)
 
243
Do not extract modification time.
 
244
By default, the modification time is set to the time stored in the archive.
 
245
.It Fl n
 
246
(c, r, u modes only)
 
247
Do not recursively archive the contents of directories.
 
248
.It Fl -newer Ar date
 
249
(c, r, u modes only)
 
250
Only include files and directories newer than the specified date.
 
251
This compares ctime entries.
 
252
.It Fl -newer-mtime Ar date
 
253
(c, r, u modes only)
 
254
Like
 
255
.Fl -newer ,
 
256
except it compares mtime entries instead of ctime entries.
 
257
.It Fl -newer-than Pa file
 
258
(c, r, u modes only)
 
259
Only include files and directories newer than the specified file.
 
260
This compares ctime entries.
 
261
.It Fl -newer-mtime-than Pa file
 
262
(c, r, u modes only)
 
263
Like
 
264
.Fl -newer-than ,
 
265
except it compares mtime entries instead of ctime entries.
 
266
.It Fl -nodump
 
267
(c and r modes only)
 
268
Honor the nodump file flag by skipping this file.
 
269
.It Fl -null
 
270
(use with
 
271
.Fl I ,
 
272
.Fl T ,
 
273
or
 
274
.Fl X )
 
275
Filenames or patterns are separated by null characters,
 
276
not by newlines.
 
277
This is often used to read filenames output by the
 
278
.Fl print0
 
279
option to
 
280
.Xr find 1 .
 
281
.It Fl -numeric-owner
 
282
(x mode only)
 
283
Ignore symbolic user and group names when restoring archives to disk,
 
284
only numeric uid and gid values will be obeyed.
 
285
.It Fl O
 
286
(x, t modes only)
 
287
In extract (-x) mode, files will be written to standard out rather than
 
288
being extracted to disk.
 
289
In list (-t) mode, the file listing will be written to stderr rather than
 
290
the usual stdout.
 
291
.It Fl o
 
292
(x mode)
 
293
Use the user and group of the user running the program rather
 
294
than those specified in the archive.
 
295
Note that this has no significance unless
 
296
.Fl p
 
297
is specified, and the program is being run by the root user.
 
298
In this case, the file modes and flags from
 
299
the archive will be restored, but ACLs or owner information in
 
300
the archive will be discarded.
 
301
.It Fl o
 
302
(c, r, u mode)
 
303
A synonym for
 
304
.Fl -format Ar ustar
 
305
.It Fl -one-file-system
 
306
(c, r, and u modes)
 
307
Do not cross mount points.
 
308
.It Fl -options Ar options
 
309
Select optional behaviors for particular modules.
 
310
The argument is a text string containing comma-separated
 
311
keywords and values.
 
312
These are passed to the modules that handle particular
 
313
formats to control how those formats will behave.
 
314
Each option has one of the following forms:
 
315
.Bl -tag -compact -width indent
 
316
.It Ar key=value
 
317
The key will be set to the specified value in every module that supports it.
 
318
Modules that do not support this key will ignore it.
 
319
.It Ar key
 
320
The key will be enabled in every module that supports it.
 
321
This is equivalent to
 
322
.Ar key Ns Cm =1 .
 
323
.It Ar !key
 
324
The key will be disabled in every module that supports it.
 
325
.It Ar module:key=value , Ar module:key , Ar module:!key
 
326
As above, but the corresponding key and value will be provided
 
327
only to modules whose name matches
 
328
.Ar module .
 
329
.El
 
330
The currently supported modules and keys are:
 
331
.Bl -tag -compact -width indent
 
332
.It Cm iso9660:joliet
 
333
Support Joliet extensions.
 
334
This is enabled by default, use
 
335
.Cm !joliet
 
336
or
 
337
.Cm iso9660:!joliet
 
338
to disable.
 
339
.It Cm iso9660:rockridge
 
340
Support Rock Ridge extensions.
 
341
This is enabled by default, use
 
342
.Cm !rockridge
 
343
or
 
344
.Cm iso9660:!rockridge
 
345
to disable.
 
346
.It Cm gzip:compression-level
 
347
A decimal integer from 0 to 9 specifying the gzip compression level.
 
348
.It Cm xz:compression-level
 
349
A decimal integer from 0 to 9 specifying the xz compression level.
 
350
.It Cm mtree: Ns Ar keyword
 
351
The mtree writer module allows you to specify which mtree keywords
 
352
will be included in the output.
 
353
Supported keywords include:
 
354
.Cm cksum , Cm device , Cm flags , Cm gid , Cm gname , Cm indent ,
 
355
.Cm link , Cm md5 , Cm mode , Cm nlink , Cm rmd160 , Cm sha1 , Cm sha256 ,
 
356
.Cm sha384 , Cm sha512 , Cm size , Cm time , Cm uid , Cm uname .
 
357
The default is equivalent to:
 
358
.Dq device, flags, gid, gname, link, mode, nlink, size, time, type, uid, uname .
 
359
.It Cm mtree:all
 
360
Enables all of the above keywords.
 
361
You can also use
 
362
.Cm mtree:!all
 
363
to disable all keywords.
 
364
.It Cm mtree:use-set
 
365
Enable generation of
 
366
.Cm /set
 
367
lines in the output.
 
368
.It Cm mtree:indent
 
369
Produce human-readable output by indenting options and splitting lines
 
370
to fit into 80 columns.
 
371
.It Cm zip:compression Ns = Ns Ar type
 
372
Use
 
373
.Ar type
 
374
as compression method.
 
375
Supported values are store (uncompressed) and deflate (gzip algorithm).
 
376
.El
 
377
If a provided option is not supported by any module, that
 
378
is a fatal error.
 
379
.It Fl P
 
380
Preserve pathnames.
 
381
By default, absolute pathnames (those that begin with a /
 
382
character) have the leading slash removed both when creating archives
 
383
and extracting from them.
 
384
Also,
 
385
.Nm
 
386
will refuse to extract archive entries whose pathnames contain
 
387
.Pa ..
 
388
or whose target directory would be altered by a symlink.
 
389
This option suppresses these behaviors.
 
390
.It Fl p
 
391
(x mode only)
 
392
Preserve file permissions.
 
393
Attempt to restore the full permissions, including owner, file modes, file
 
394
flags and ACLs, if available, for each item extracted from the archive.
 
395
By default, newly-created files are owned by the user running
 
396
.Nm ,
 
397
the file mode is restored for newly-created regular files, and
 
398
all other types of entries receive default permissions.
 
399
If
 
400
.Nm
 
401
is being run by root, the default is to restore the owner unless the
 
402
.Fl o
 
403
option is also specified.
 
404
.It Fl q ( Fl -fast-read )
 
405
(x and t mode only)
 
406
Extract or list only the first archive entry that matches each pattern
 
407
or filename operand.
 
408
Exit as soon as each specified pattern or filename has been matched.
 
409
By default, the archive is always read to the very end, since
 
410
there can be multiple entries with the same name and, by convention,
 
411
later entries overwrite earlier entries.
 
412
This option is provided as a performance optimization.
 
413
.It Fl S
 
414
(x mode only)
 
415
Extract files as sparse files.
 
416
For every block on disk, check first if it contains only NULL bytes and seek
 
417
over it otherwise.
 
418
This works similiar to the conv=sparse option of dd.
 
419
.It Fl -strip-components Ar count
 
420
(x mode only)
 
421
Remove the specified number of leading path elements.
 
422
Pathnames with fewer elements will be silently skipped.
 
423
Note that the pathname is edited after checking inclusion/exclusion patterns
 
424
but before security checks.
 
425
.It Fl s Ar pattern
 
426
Modify file or archive member names according to
 
427
.Pa pattern .
 
428
The pattern has the format
 
429
.Ar /old/new/ Ns Op gps
 
430
where
 
431
.Ar old
 
432
is a basic regular expression,
 
433
.Ar new
 
434
is the replacement string of the matched part,
 
435
and the optional trailing letters modify
 
436
how the replacement is handled.
 
437
If
 
438
.Ar old
 
439
is not matched, the pattern is skipped.
 
440
Within
 
441
.Ar new ,
 
442
~ is substituted with the match, \e1 to \e9 with the content of
 
443
the corresponding captured group.
 
444
The optional trailing g specifies that matching should continue
 
445
after the matched part and stopped on the first unmatched pattern.
 
446
The optional trailing s specifies that the pattern applies to the value
 
447
of symbolic links.
 
448
The optional trailing p specifies that after a successful substitution
 
449
the original path name and the new path name should be printed to
 
450
standard error.
 
451
.It Fl T Ar filename
 
452
In x or t mode,
 
453
.Nm
 
454
will read the list of names to be extracted from
 
455
.Pa filename .
 
456
In c mode,
 
457
.Nm
 
458
will read names to be archived from
 
459
.Pa filename .
 
460
The special name
 
461
.Dq -C
 
462
on a line by itself will cause the current directory to be changed to
 
463
the directory specified on the following line.
 
464
Names are terminated by newlines unless
 
465
.Fl -null
 
466
is specified.
 
467
Note that
 
468
.Fl -null
 
469
also disables the special handling of lines containing
 
470
.Dq -C .
 
471
.It Fl U
 
472
(x mode only)
 
473
Unlink files before creating them.
 
474
Without this option,
 
475
.Nm
 
476
overwrites existing files, which preserves existing hardlinks.
 
477
With this option, existing hardlinks will be broken, as will any
 
478
symlink that would affect the location of an extracted file.
 
479
.It Fl -use-compress-program Ar program
 
480
Pipe the input (in x or t mode) or the output (in c mode) through
 
481
.Pa program
 
482
instead of using the builtin compression support.
 
483
.It Fl v
 
484
Produce verbose output.
 
485
In create and extract modes,
 
486
.Nm
 
487
will list each file name as it is read from or written to
 
488
the archive.
 
489
In list mode,
 
490
.Nm
 
491
will produce output similar to that of
 
492
.Xr ls 1 .
 
493
Additional
 
494
.Fl v
 
495
options will provide additional detail.
 
496
.It Fl -version
 
497
Print version of
 
498
.Nm
 
499
and
 
500
.Nm libarchive ,
 
501
and exit.
 
502
.It Fl w
 
503
Ask for confirmation for every action.
 
504
.It Fl X Ar filename
 
505
Read a list of exclusion patterns from the specified file.
 
506
See
 
507
.Fl -exclude
 
508
for more information about the handling of exclusions.
 
509
.It Fl y
 
510
(c mode only)
 
511
Compress the resulting archive with
 
512
.Xr bzip2 1 .
 
513
In extract or list modes, this option is ignored.
 
514
Note that, unlike other
 
515
.Nm tar
 
516
implementations, this implementation recognizes bzip2 compression
 
517
automatically when reading archives.
 
518
.It Fl z
 
519
(c mode only)
 
520
Compress the resulting archive with
 
521
.Xr gzip 1 .
 
522
In extract or list modes, this option is ignored.
 
523
Note that, unlike other
 
524
.Nm tar
 
525
implementations, this implementation recognizes gzip compression
 
526
automatically when reading archives.
 
527
.It Fl Z
 
528
(c mode only)
 
529
Compress the resulting archive with
 
530
.Xr compress 1 .
 
531
In extract or list modes, this option is ignored.
 
532
Note that, unlike other
 
533
.Nm tar
 
534
implementations, this implementation recognizes compress compression
 
535
automatically when reading archives.
 
536
.El
 
537
.Sh EXIT STATUS
 
538
.Ex -std
 
539
.Sh ENVIRONMENT
 
540
The following environment variables affect the execution of
 
541
.Nm :
 
542
.Bl -tag -width ".Ev BLOCKSIZE"
 
543
.It Ev LANG
 
544
The locale to use.
 
545
See
 
546
.Xr environ 7
 
547
for more information.
 
548
.It Ev TAPE
 
549
The default tape device.
 
550
The
 
551
.Fl f
 
552
option overrides this.
 
553
.It Ev TZ
 
554
The timezone to use when displaying dates.
 
555
See
 
556
.Xr environ 7
 
557
for more information.
 
558
.El
 
559
.Sh FILES
 
560
.Bl -tag -width ".Ev BLOCKSIZE"
 
561
.It Pa /dev/sa0
 
562
The default tape device, if not overridden by the
 
563
.Ev TAPE
 
564
environment variable or the
 
565
.Fl f
 
566
option.
 
567
.El
 
568
.Sh EXAMPLES
 
569
The following creates a new archive
 
570
called
 
571
.Ar file.tar.gz
 
572
that contains two files
 
573
.Ar source.c
 
574
and
 
575
.Ar source.h :
 
576
.Dl Nm Fl czf Pa file.tar.gz Pa source.c Pa source.h
 
577
.Pp
 
578
To view a detailed table of contents for this
 
579
archive:
 
580
.Dl Nm Fl tvf Pa file.tar.gz
 
581
.Pp
 
582
To extract all entries from the archive on
 
583
the default tape drive:
 
584
.Dl Nm Fl x
 
585
.Pp
 
586
To examine the contents of an ISO 9660 cdrom image:
 
587
.Dl Nm Fl tf Pa image.iso
 
588
.Pp
 
589
To move file hierarchies, invoke
 
590
.Nm
 
591
as
 
592
.Dl Nm Fl cf Pa - Fl C Pa srcdir\ . | Nm Fl xpf Pa - Fl C Pa destdir
 
593
or more traditionally
 
594
.Dl cd srcdir \&; Nm Fl cf Pa -\ . | ( cd destdir \&; Nm Fl xpf Pa - )
 
595
.Pp
 
596
In create mode, the list of files and directories to be archived
 
597
can also include directory change instructions of the form
 
598
.Cm -C Ns Pa foo/baz
 
599
and archive inclusions of the form
 
600
.Cm @ Ns Pa archive-file .
 
601
For example, the command line
 
602
.Dl Nm Fl c Fl f Pa new.tar Pa foo1 Cm @ Ns Pa old.tgz Cm -C Ns Pa /tmp Pa foo2
 
603
will create a new archive
 
604
.Pa new.tar .
 
605
.Nm
 
606
will read the file
 
607
.Pa foo1
 
608
from the current directory and add it to the output archive.
 
609
It will then read each entry from
 
610
.Pa old.tgz
 
611
and add those entries to the output archive.
 
612
Finally, it will switch to the
 
613
.Pa /tmp
 
614
directory and add
 
615
.Pa foo2
 
616
to the output archive.
 
617
.Pp
 
618
An input file in
 
619
.Xr mtree 5
 
620
format can be used to create an output archive with arbitrary ownership,
 
621
permissions, or names that differ from existing data on disk:
 
622
.Pp
 
623
.Dl $ cat input.mtree
 
624
.Dl #mtree
 
625
.Dl usr/bin uid=0 gid=0 mode=0755 type=dir
 
626
.Dl usr/bin/ls uid=0 gid=0 mode=0755 type=file content=myls
 
627
.Dl $ tar -cvf output.tar @input.mtree
 
628
.Pp
 
629
The
 
630
.Fl -newer
 
631
and
 
632
.Fl -newer-mtime
 
633
switches accept a variety of common date and time specifications, including
 
634
.Dq 12 Mar 2005 7:14:29pm ,
 
635
.Dq 2005-03-12 19:14 ,
 
636
.Dq 5 minutes ago ,
 
637
and
 
638
.Dq 19:14 PST May 1 .
 
639
.Pp
 
640
The
 
641
.Fl -options
 
642
argument can be used to control various details of archive generation
 
643
or reading.
 
644
For example, you can generate mtree output which only contains
 
645
.Cm type , Cm time ,
 
646
and
 
647
.Cm uid
 
648
keywords:
 
649
.Dl Nm Fl cf Pa file.tar Fl -format=mtree Fl -options='!all,type,time,uid' Pa dir
 
650
or you can set the compression level used by gzip or xz compression:
 
651
.Dl Nm Fl czf Pa file.tar Fl -options='compression-level=9' .
 
652
For more details, see the explanation of the
 
653
.Fn archive_read_set_options
 
654
and
 
655
.Fn archive_write_set_options
 
656
API calls that are described in
 
657
.Xr archive_read 3
 
658
and
 
659
.Xr archive_write 3 .
 
660
.Sh COMPATIBILITY
 
661
The bundled-arguments format is supported for compatibility
 
662
with historic implementations.
 
663
It consists of an initial word (with no leading - character) in which
 
664
each character indicates an option.
 
665
Arguments follow as separate words.
 
666
The order of the arguments must match the order
 
667
of the corresponding characters in the bundled command word.
 
668
For example,
 
669
.Dl Nm Cm tbf 32 Pa file.tar
 
670
specifies three flags
 
671
.Cm t ,
 
672
.Cm b ,
 
673
and
 
674
.Cm f .
 
675
The
 
676
.Cm b
 
677
and
 
678
.Cm f
 
679
flags both require arguments,
 
680
so there must be two additional items
 
681
on the command line.
 
682
The
 
683
.Ar 32
 
684
is the argument to the
 
685
.Cm b
 
686
flag, and
 
687
.Ar file.tar
 
688
is the argument to the
 
689
.Cm f
 
690
flag.
 
691
.Pp
 
692
The mode options c, r, t, u, and x and the options
 
693
b, f, l, m, o, v, and w comply with SUSv2.
 
694
.Pp
 
695
For maximum portability, scripts that invoke
 
696
.Nm tar
 
697
should use the bundled-argument format above, should limit
 
698
themselves to the
 
699
.Cm c ,
 
700
.Cm t ,
 
701
and
 
702
.Cm x
 
703
modes, and the
 
704
.Cm b ,
 
705
.Cm f ,
 
706
.Cm m ,
 
707
.Cm v ,
 
708
and
 
709
.Cm w
 
710
options.
 
711
.Pp
 
712
Additional long options are provided to improve compatibility with other
 
713
tar implementations.
 
714
.Sh SECURITY
 
715
Certain security issues are common to many archiving programs, including
 
716
.Nm .
 
717
In particular, carefully-crafted archives can request that
 
718
.Nm
 
719
extract files to locations outside of the target directory.
 
720
This can potentially be used to cause unwitting users to overwrite
 
721
files they did not intend to overwrite.
 
722
If the archive is being extracted by the superuser, any file
 
723
on the system can potentially be overwritten.
 
724
There are three ways this can happen.
 
725
Although
 
726
.Nm
 
727
has mechanisms to protect against each one,
 
728
savvy users should be aware of the implications:
 
729
.Bl -bullet -width indent
 
730
.It
 
731
Archive entries can have absolute pathnames.
 
732
By default,
 
733
.Nm
 
734
removes the leading
 
735
.Pa /
 
736
character from filenames before restoring them to guard against this problem.
 
737
.It
 
738
Archive entries can have pathnames that include
 
739
.Pa ..
 
740
components.
 
741
By default,
 
742
.Nm
 
743
will not extract files containing
 
744
.Pa ..
 
745
components in their pathname.
 
746
.It
 
747
Archive entries can exploit symbolic links to restore
 
748
files to other directories.
 
749
An archive can restore a symbolic link to another directory,
 
750
then use that link to restore a file into that directory.
 
751
To guard against this,
 
752
.Nm
 
753
checks each extracted path for symlinks.
 
754
If the final path element is a symlink, it will be removed
 
755
and replaced with the archive entry.
 
756
If
 
757
.Fl U
 
758
is specified, any intermediate symlink will also be unconditionally removed.
 
759
If neither
 
760
.Fl U
 
761
nor
 
762
.Fl P
 
763
is specified,
 
764
.Nm
 
765
will refuse to extract the entry.
 
766
.El
 
767
To protect yourself, you should be wary of any archives that
 
768
come from untrusted sources.
 
769
You should examine the contents of an archive with
 
770
.Dl Nm Fl tf Pa filename
 
771
before extraction.
 
772
You should use the
 
773
.Fl k
 
774
option to ensure that
 
775
.Nm
 
776
will not overwrite any existing files or the
 
777
.Fl U
 
778
option to remove any pre-existing files.
 
779
You should generally not extract archives while running with super-user
 
780
privileges.
 
781
Note that the
 
782
.Fl P
 
783
option to
 
784
.Nm
 
785
disables the security checks above and allows you to extract
 
786
an archive while preserving any absolute pathnames,
 
787
.Pa ..
 
788
components, or symlinks to other directories.
 
789
.Sh SEE ALSO
 
790
.Xr bzip2 1 ,
 
791
.Xr compress 1 ,
 
792
.Xr cpio 1 ,
 
793
.Xr gzip 1 ,
 
794
.Xr mt 1 ,
 
795
.Xr pax 1 ,
 
796
.Xr shar 1 ,
 
797
.Xr libarchive 3 ,
 
798
.Xr libarchive-formats 5 ,
 
799
.Xr tar 5
 
800
.Sh STANDARDS
 
801
There is no current POSIX standard for the tar command; it appeared
 
802
in
 
803
.St -p1003.1-96
 
804
but was dropped from
 
805
.St -p1003.1-2001 .
 
806
The options used by this implementation were developed by surveying a
 
807
number of existing tar implementations as well as the old POSIX specification
 
808
for tar and the current POSIX specification for pax.
 
809
.Pp
 
810
The ustar and pax interchange file formats are defined by
 
811
.St -p1003.1-2001
 
812
for the pax command.
 
813
.Sh HISTORY
 
814
A
 
815
.Nm tar
 
816
command appeared in Seventh Edition Unix, which was released in January, 1979.
 
817
There have been numerous other implementations,
 
818
many of which extended the file format.
 
819
John Gilmore's
 
820
.Nm pdtar
 
821
public-domain implementation (circa November, 1987)
 
822
was quite influential, and formed the basis of GNU tar.
 
823
GNU tar was included as the standard system tar
 
824
in
 
825
.Fx
 
826
beginning with
 
827
.Fx 1.0 .
 
828
.Pp
 
829
This is a complete re-implementation based on the
 
830
.Xr libarchive 3
 
831
library.
 
832
.Sh BUGS
 
833
This program follows
 
834
.St -p1003.1-96
 
835
for the definition of the
 
836
.Fl l
 
837
option.
 
838
Note that GNU tar prior to version 1.15 treated
 
839
.Fl l
 
840
as a synonym for the
 
841
.Fl -one-file-system
 
842
option.
 
843
.Pp
 
844
The
 
845
.Fl C Pa dir
 
846
option may differ from historic implementations.
 
847
.Pp
 
848
All archive output is written in correctly-sized blocks, even
 
849
if the output is being compressed.
 
850
Whether or not the last output block is padded to a full
 
851
block size varies depending on the format and the
 
852
output device.
 
853
For tar and cpio formats, the last block of output is padded
 
854
to a full block size if the output is being
 
855
written to standard output or to a character or block device such as
 
856
a tape drive.
 
857
If the output is being written to a regular file, the last block
 
858
will not be padded.
 
859
Many compressors, including
 
860
.Xr gzip 1
 
861
and
 
862
.Xr bzip2 1 ,
 
863
complain about the null padding when decompressing an archive created by
 
864
.Nm ,
 
865
although they still extract it correctly.
 
866
.Pp
 
867
The compression and decompression is implemented internally, so
 
868
there may be insignificant differences between the compressed output
 
869
generated by
 
870
.Dl Nm Fl czf Pa - file
 
871
and that generated by
 
872
.Dl Nm Fl cf Pa - file | Nm gzip
 
873
.Pp
 
874
The default should be to read and write archives to the standard I/O paths,
 
875
but tradition (and POSIX) dictates otherwise.
 
876
.Pp
 
877
The
 
878
.Cm r
 
879
and
 
880
.Cm u
 
881
modes require that the archive be uncompressed
 
882
and located in a regular file on disk.
 
883
Other archives can be modified using
 
884
.Cm c
 
885
mode with the
 
886
.Pa @archive-file
 
887
extension.
 
888
.Pp
 
889
To archive a file called
 
890
.Pa @foo
 
891
or
 
892
.Pa -foo
 
893
you must specify it as
 
894
.Pa ./@foo
 
895
or
 
896
.Pa ./-foo ,
 
897
respectively.
 
898
.Pp
 
899
In create mode, a leading
 
900
.Pa ./
 
901
is always removed.
 
902
A leading
 
903
.Pa /
 
904
is stripped unless the
 
905
.Fl P
 
906
option is specified.
 
907
.Pp
 
908
There needs to be better support for file selection on both create
 
909
and extract.
 
910
.Pp
 
911
There is not yet any support for multi-volume archives or for archiving
 
912
sparse files.
 
913
.Pp
 
914
Converting between dissimilar archive formats (such as tar and cpio) using the
 
915
.Cm @ Ns Pa -
 
916
convention can cause hard link information to be lost.
 
917
(This is a consequence of the incompatible ways that different archive
 
918
formats store hardlink information.)
 
919
.Pp
 
920
There are alternative long options for many of the short options that
 
921
are deliberately not documented.