tar(1)
NAME
tar, mdtar − multivolume tape archivers
SYNTAX
tar [ −C directory ] [ keys ] [ file... ]
mdtar [ −C directory ] [ keys ] [ file... ]
DESCRIPTION
The tar and mdtar commands save/restore each named file or all files in the named directory to/from a single archive file/volume or multiple archives/volumes. When invoked, tar assumes that the output file is a magnetic tape unless indicated otherwise by command line keys. The mdtar command assumes that the output file is an 800 block rx50.
The tar command supports the /USER/GROUP standard archive header formats. For further information, see tar(5).
The tar command supports multivolume operations. When tar output is directed to a tape device, tar continues the output file set to another volume when EOT (end-of-tape) is detected. However, tar requests an archive change when the current output archive is filled. Additionally, tar automatically splits a file larger than a single archives’ capacity to as many archives as are required to contain the file.
When restoring files from an archive, tar requests a media change if the last/only file on the media is continued on another volume. Tape volumes and disk archives contain volume numbers that are used to detect an out-of-sequence restoration. If volumes/archives containing continued files are not restored in the proper sequence, tar issues an appropriate error message. Volume/archive numbers begin at 1 and increment by 1 for each archive/volume in the set. For further information, see tar(5).
Individual or selected files may be restored from any volume in the set. However, a file that spans more than one volume/archive can only be restored by presenting tar with the volumes/archives in the correct order. A table of contents ( V modifier) can be used to determine the current volume/archive sequence.
In the follow descriptions, the word “tape” normally implies a singular physical device object such as reel of magnetic tape or removable disk. Discussions regarding multivolume operations do not apply if the tar input/output object is a disk file or stdin/stdout.
OPTIONS
−C Changes working directory to the named directory (next argument). This allows multiple directories not related by a close common parent to be archived using short relative path names. For example, to archive files from /usr/include and from /etc, use:
tar c -C /usr/include -C /etc
The tar command correctly restore all directory components in a given path. That is, subdirectory ownership and modes are preserved on the output archive and restored on an extract.
KEYS
The key is a string of characters containing at most one function letter and possibly one or more function modifiers.
c Creates a new tape archive. Output starts on the beginning of the tape instead of after the last file.
r Writes each named file to the end of an existing tape archive.
t Lists the names of the files as they occur on the tape.
u Adds each named file to the tape either if it is not there already or if it has been modified since last put on the tape.
x Extracts each named file from an existing tape archive. If the named file matches a directory whose contents had been written onto the tape, this directory is (recursively) extracted. The owner, modification time, and mode are restored (if possible). If no file argument is given, the entire content of the tape is extracted. If multiple entries specifying the same file are on the tape, the last one overwrites all previously extracted copies.
The following modifier character can be used in addition to the key to select the function desired.
A Uses the next argument as the archive number to begin output. This modifier is intended for write-error recovery on nontape devices only. It should not be used for tape archives, since tar has no accurate way to determine how much information can be contained on a volume in advance. The tar command writes files in terms of archives. Each archive contains a number of files. If tar has been requested to dump a path (set of files) that, for example, consist of 10 archives and if there is an error writing the nth archive, then the A modifier can be used to restart tar at a later time at the nth archive. You must issue the same path (set of files) as in the first command. This will guarantee that tar will begin at the correct file on Archive n. If an error occurs during a write, tar will automatically attempt to rewrite the current archive. If the error recurs, the operation can be aborted with a <CTRL/C> and rerun using the A key after the error condition has been corrected.
B Invokes logic to deal with reads of blocks of data less than 512 bytes which frequently occur when transferring large groups of files across a network link. It should be specified on both the creating tar command and the extracting tar command. For example,
tar cfB - filenames | rsh machinename \(cd todir\; tar xfB - \)
This modifier must not be specified when directing tar output to real tapes since it disables the EOT detection used for multiarchive operations.
b Uses the next argument as the blocking factor for tape records. The default is 20 (the maximum). The block size is determined automatically when reading tapes (x and t keys).
D Specifies directory information to be output as in previous versions of tar. This key conserves memory space for link table information by disabling the logic that tar uses to output directory files. It also decreases the amount of informtaion placed on the output archive. The default action of this version of tar is to place enough information about every directory in a given path such that each and every directory in a given path on the output archive may be recreated correctly. Previous version of tar were unable to perform this action.
Given the path name /usr/staff1/directory, older versions of tar would output a directory entry of the form:
/usr/staff1/directory/
This would contain only information about the directory entry “directory”. This version of tar will normally output three separate directory entries:
/usr/
/usr/staff1/
/usr/staff1/directory/
Each entry will contain the correct file modes, ownership, and persmissions of the orginal file thus enabling exact recreation of the path if you restore the archive as superuser with the p modifier.
In order to avoid duplicate entrys on the output archive, tar builds a table of each directory output. When tar runs out of memory space for directory entrys, it will return the list of directories to free-memory and, if possible, begin a new list. The list is returned to free-memory to provide malloc space for hard-link table entries. If sufficient memory cannot be obtained for a directory path component, tar will output the directory path as in v7tar.
Additionally, tar allocates enough memory, using malloc, for the default block size (20) at start up time. A savings of memory for link and/or directory tables can be obtained by specifying a smaller block size. For example,
tar cvb 10 /
This would allow an additional 10*TBLOCK bytes (5120 decimal) for allocation to the directory and/or link tables. Normally, tar will not use all of its available memory. However, these points are discussed here in case a very large disk containing a great number of directories and/or hard-link files is being processed.
d Select RX50 as the archive media. Blocking factor of 20 for output. The default device name is /dev/rrx1.
F[F] Operates in fast mode. When F is specified, tar skips all SCCS directories, core files, and errs files. When FF is specified, tar also skips all a.out and *.o files.
f Uses the next argument as the name of the archive instead of /dev/rmt?. If − is specified for a file name, tar writes to standard output or reads from standard input, whichever is appropriate. Thus, tar can be used as the head or tail of a filter chain. When either stdin or stdout is specified, tar enforces a block size of one regardless of any other explicitely given sizes. The tar command can also be used to move hierarchies with the command:
cd fromdir; tar cf - . | (cd todir; tar xf -)
g Uses /dev/rgt0 as the default archive.
H Prints a help summary of the available keys.
h Writes a copy of a symbolically linked file/directory placed on the tape instead of the symbolic link itself. Normally, tar places symbolic links themselves on the output tape rather than the objects they point to.
i Ignores checksum errors found on the input archive and tells tar to attempt to continue reading data.
k Uses /dev/rtk0 as the default device.
l Issues a warning message if all links to the files dumped cannot be found. If this key is not specified, no warning messages are printed. The link resolution errors (if any) are printed at the end of the current operation.
M Specifies the maximum archve number to be written (next argument). Valid archive numbers are 1-99. This key also causes tar to include the number of the current archive in the verbose output.
m Does not restore the modification times. The modification time will be the time of extraction.
N Suppresses multivolume, file-splitting, and new (/USER/GROUP) header format on output. That is, if used in conjunction with the D key, suppress these features and produces a volume in the same manner as v7tar. Also, on input, this key indicates that the user and group IDs of the file are to be obtained from the tar file header rather than from the /etc/passwd and /etc/group files, as specified by the /USER/GROUP standard.
n Select /dev/rmt0 as the default device.
O Additionally outputs file owner and group names for t and x keys. For c, r, and u keys, additionally issues a warning message if the file owner’s user and/or group IDs cannot be found in the /etc/passwd or /etc/group files, respectively.
o Suppresses the normal directory information. On output, tar normally places information specifying owner and modes of directories in the archive. Former versions of tar, when reading this information will give error message of the form:
"<name>/: cannot create".
p Restores the named files to their original modes, ignoring the present mask. For further information, see umask(2). Setuid and sticky information will also be restored to the superuser.
S Creates output with /USER/GROUP standard archive headers. That is, does not include the multivolume extension fields. For further information, see tar(5).
s Uses the next argument as the size of the output archive media in 512-byte blocks. This enables tar to be used with devices of different physical media sizes. For mdtar, the default is 800 blocks (assumption is an RX50 output Archive). The tar command assumes the output device /dev/rht0 and does not define a block size for tapes.
V Displays expanded verbose information. The tar command displays information about each current operation: number of blocks used on the media is given at the end of the operation if this key is given. Additionally, a summary of hard-links and directories created on output is printed at the end of the operation. For example:
tar: links = 5/0 directories = 3/0/0
For links, the first number (5) indicates the number of hard-links created, while the second number (0) indicates the number of hard-links not created because of a lack of memory. For directories, the first number (3) indicates the number of new format directory components created. The second number (0) indicates the number of old v7tar directory components created. The third number (0) indicates the number of times that the directory list had to be returned to free memory (see D key).
v Writes the name of each file treated (preceded by the function letter) to diagnostic output. Normally, tar does its work silently. With the t modifier, this key gives more information about the tape entries than just their names. The V modifier may be used to display further information about the current operation.
w Prints the action to be taken followed by file name, then wait for user confirmation. If a word beginning with y is given, the action is done. Any other input means ignore this file.
0...9 Selects the named drive as an alternate drive on which the tape is mounted. The default is drive 0 at 1600 bpi (normally /dev/rht0).
RESTRICTIONS
There is no way to ask for the n-th occurrence of a file.
The u modifier can be slow.
The current limit on file name length is 100 characters.
There is no way to follow symbolic links selectively.
DIAGNOSTICS
Complaints about bad key characters and tape read/write errors.
Complaints if enough memory is not available to hold the link tables.
FILES
/dev/rgt0, /dev/rht0, /dev/rmt0, /dev/rrx1, /dev/rtk0
/tmp/tar*