⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tar.texinfo

📁 speech signal process tools
💻 TEXINFO
📖 第 1 页 / 共 4 页
字号:
@item -k (+keep-old-files)The @samp{-k} option prevents @code{tar} from over-writing existingfiles with files with the same name from the archive.The @samp{-k} option is meaningless with @samp{-t}.@item -K (+starting-file) @var{filename}The @samp{-K} option causes @code{tar} to begin extracting or listingthe archive with the file @var{filename}, and to consider only thefiles starting at that point in the archive.  This is useful if aprevious attempt to extract files failed when it reached@var{filename} due to lack of free space.  (This assumes, of course,that there is now free space, or that you are now extracting into adifferent file system.)@item -m@item +modification-timeWhen this option is used, @code{tar} leaves the modification times ofthe files it extracts as the time when the files were extracted,instead of setting it to the time recorded in the archive.This option is meaningless with @samp{-t}.@item -O@itemx +to-stdoutWhen this option is used, instead of creating the files specified,@code{tar} writes the contents of the files extracted to its standardoutput.  This may be useful if you are only extracting the files inorder to send them through a pipe.This option is meaningless with @samp{-t}.@item -p@itemx +same-permissions@itemx +preserve-permissionsThis option causes @code{tar} to set the modes (access permissions) ofextracted files exactly as recorded in the archive.  If this option isnot used, the current @code{umask} setting limits the permissions onextracted files.This option is meaningless with @samp{-t}.@item -P@itemx +absolute-pathsThis option should be used when the absolute pathname of a file shouldbe preserved in the archive.  @code{tar} normally strips the leading `/'from the name of the file, thus making /usr/foo/bar/baz intousr/foo/bar/baz.  Using the @samp{-P} option keeps the pathname intact,and is useful in that it is not necessary to change to the rootdirectory when extracting files.@item -s@itemx +same-order@itemx +preserve-orderThis option tells @code{tar} that the list of filenames to be listed orextracted is sorted in the same order as the files in the archive.  Thisallows a large list of names to be used, even on a small machine thatwould not otherwise be able to hold all the names in memory at the sametime.  Such a sorted list can easily be created by running @samp{tar -t}on the archive and editing its output.This option is probably never needed on modern computer systems.@item +preserveThe @samp{+preserve} option has no equivalent short option name.It is equivalent to @samp{-p} plus @samp{-s}.@end table@node Option Syntax, , Extraction Options, Options@section Old Syntax for OptionsFor compatibility with Unix @code{tar}, the first argument can containoption letters in addition to the command letter; for example, @samp{tarcv} specifies the option @samp{-v} in addition to the command @samp{-c}.The first argument to GNU @code{tar} is always treated as command andoption letters even if it doesn't start with @samp{-}.Some options need their own arguments; for example, @samp{-f} is followedby the name of the archive file.  When the option is given separately, itsargument follows it, as is usual for Unix programs.  For example:@exampletar -c -v -b 20 -f /dev/rmt0@end exampleWhen options that need arguments are given together with the command, allthe associated arguments follow, in the same order as the options.  Thus,the example above could also be written in the old style as follows:@exampletar cvbf 20 /dev/rmt0@end example@noindentHere @samp{20} is the argument of @samp{-b} and @file{/dev/rmt0} is theargument of @samp{-f}.The long-named options can be used instead of the single-letter flags.They are meant to be obvious and easy to remember, possibly more so thantheir corresponding single-letter options.  The above example usinglong-named options would look like this:@exampletar +create +verbose +block-size +file 20 /dev/rmt0@end example@node FullDumps, IncDumps, Options, Top@chapter Using @code{tar} to Perform Full DumpsFull dumps should only be made when no other people or programs aremodifying files in the filesystem.  If files are modified while@code{tar} is making the backup, they may not be stored properly inthe archive, in which case you won't be able to restore them if youhave to.You will want to use the @samp{-V} option to give the archive avolume label, so you can tell what this archive is even if the labelfalls off the tape, or anything like that.Unless the filesystem you are dumping is guaranteed to fit on onevolume, you will need to use the @samp{-M} option.  Make sure youhave enough tapes on hand to complete the backup.If you want to dump each filesystem separately you will need to usethe @samp{-l} option to prevent @code{tar} from crossing filesystemboundaries when storing (sub)directories.The @samp{-G} option is not needed, since this is a complete copy ofeverything in the filesystem, and a full restore from this backupwould only be done onto a completely empty disk.Unless you are in a hurry, and trust the @code{tar} program (andyour tapes), it is a good idea to use the @code{-W} (verify) option,to make sure your files really made it onto the dump properly.  Thiswill also detect cases where the file was modified while (or justafter) it was being archived.@node IncDumps, Problems, FullDumps, Top@chapter Using @code{tar} to Perform Incremental DumpsPerforming incremental dumps is similar to performing full dumps,although a few more options will usually be needed.You will need to use the @samp{-N @var{date}} option to tell @code{tar} toonly store files that have been modified since @var{date}.@var{date} should be the date and time of the last full/incrementaldump.A standard scheme is to do a @samp{monthly} (full) dump once a month,a @samp{weekly} dump once a week of everything since the last monthly anda @samp{daily} every day of everything since the last (weekly or monthly)dump.Here is a copy of the script used to dump the filesystems of themachines here at the Free Software Foundation.  This script is run(semi-)automatically late at night when people are least likely tobe using the machines.  This script dumps several filesystems fromseveral machines at once (by using a network-filesystem).  Theoperator is responsible for ensuring that all the machines will beup at the time the dump happens.  If a machine is not running, itsfiles will not be dumped, and the next day's incremental dump will@emph{not} store files that would have gone onto that dump.@example#!/bin/csh# Dump thingieset now = `date`set then = `cat date.nfs.dump`/u/hack/bin/tar -c -G -v\ -f /dev/rtu20\ -b 126\ -N "$then"\ -V "Dump from $then to $now"\ /alpha-bits/gp\ /gnu/hack\ /hobbes/u\ /spiff/u\ /sugar-bombs/uecho $now > date.nfs.dumpmt -f /dev/rtu20 rew@end exampleOutput from this script is stored in a file, for the operator toread later.This script uses the file @file{date.nfs.dump} to store the date/time ofthe last dump.Since this is a streaming tape drive, no attempt to verify thearchive is done.  This is also why the high blocking factor (126) isused.  The tape drive must also be rewound by the @code{mt} commandafter the dump is made.@node Problems, Rem Tape, IncDumps, Top@chapter Common Problems Using @code{tar}Unless you use the @code{-P} option, GNU @code{tar} will not allowyou to create an archive that contains absolute pathnames.  (Anabsolute pathname is one that begins with a @samp{/}.) If you try,@code{tar} will automatically remove the leading @samp{/} from thefile names it stores in the archive.  It will also type a warningmessage telling you what it is doing.When reading an archive that was created with a different @code{tar}program, GNU @code{tar} automatically extracts entries in thearchive which have absolute pathnames as if the pathnames were notabsolute.  If the archive contained a file @samp{/usr/bin/computoy},GNU @code{tar} would extract the file to @samp{usr/bin/computoy} inthe current directory.  If you want to extract the files in anarchive to the same absolute names that they had when the archivewas created, you should do a @samp{cd /} before extracting the filesfrom the archive, or you should either use the @samp{-P} option, oruse the command @samp{tar -C / @dots{}}.Some versions of UNIX, (Ultrix 3.1 is know to have this problem) canclaim that a short write near the end of a tape succeeded, when itactually failed.  This will result in the -M option not workingcorrectly.  The best workaround at the moment is to use asignificantly larger blocksize than the default 20.In order to update an archive, @code{tar} must be able to backspacethe archive in order to re-read or re-write a block that was just read(or written).  This is currently possible only on two kinds offiles:  normal disk files (or any other file that can bebackspaced with @code{lseek()}), and industry-standard 9-track magnetictape (or any other kind of tape that can be backspaced with@code{ioctl(@dots{},MTIOCTOP,@dots{})}).This means that the @samp{-r}, @samp{-u}, @samp{-A}, and @samp{-D}commands will not work on any other kind of file.  Some media simplycannot be backspaced, which means these commands and options willnever be able to work on them.  These non-backspacing media includepipes and cartridge tape drives.Some other media can be backspaced, and @code{tar} will work on themonce @code{tar} is modified to do so.Archives created with the @samp{-M}, @samp{-V}, and @samp{-G}options may not be readable by other version of @code{tar}.  In particular,restoring a file that was split over a volume boundary will requiresome careful work with @code{dd}, if it can be done at all.  Other versionsof @code{tar} may also create an empty file whose name is that ofthe volume header.  Some versions of @code{tar} may create normalfiles instead of directories archived with the @samp{-G} option.@node Rem Tape, Format, Problems, Top@chapter The Remote Tape ServerIn order to access the tape drive on a remote machine, @code{tar}uses the remote tape server written at the University of Californiaat Berkeley.  The remote tape server must be installed as@file{/etc/rmt} on any machine whose tape drive you want to use.@code{tar} calls @file{/etc/rmt} by running an @code{rsh} or@code{remsh} to the remote machine, optionally using a differentlogin name if one is supplied.A copy of the source for the remote tape server is provided.  It isCopyright @copyright{} 1983 by the Regents of the University of California, butcan be freely distributed.  Instructions for compiling andinstalling it are included in the @file{Makefile}.The remote tape server may need to be modified in order to run on anon-4.3BSD system.@node Format, , Rem Tape, Top@chapter The Format of a @code{tar} ArchiveThis chapter is based heavily on John Gilmore's @i{tar}(5) manual pagefor the public domain @code{tar} that GNU @code{tar} is based on.@section The Standard FormatA @dfn{tar tape} or file contains a series of records.  Each recordcontains @code{RECORDSIZE} bytes.  Although this format may bethought of as being on magnetic tape, other media are often used.Each file archived is represented by a header record which describesthe file, followed by zero or more records which give the contentsof the file.  At the end of the archive file there may be a recordfilled with binary zeros as an end-of-file marker.  A reasonablesystem should write a record of zeros at the end, but must notassume that such a record exists when reading an archive.The records may be @dfn{blocked} for physical I/O operations.  Eachblock of @var{N} records (where @var{N} is set by the @samp{-b}option to @code{tar}) is written with a single @code{write()}operation.  On magnetic tapes, the result of such a write is asingle tape record.  When writing an archive, the last block ofrecords should be written at the full size, with records after thezero record containing all zeroes.  When reading an archive, areasonable system should properly handle an archive whose last blockis shorter than the rest, or which contains garbage records after azero record.The header record is defined in C as follows:@example/* * Standard Archive Format - Standard TAR - USTAR */#define RECORDSIZE  	512#define NAMSIZ      	100#define TUNMLEN      	32#define TGNMLEN      	32#define SPARSE_EXT_HDR	21#define	SPARSE_IN_HDR	4struct sparse @{	char offset[12];	char numbytes[12];@};union record @{    char        charptr[RECORDSIZE];    struct header @{        char    name[NAMSIZ];        char    mode[8];        char    uid[8];        char    gid[8];        char    size[12];        char    mtime[12];        char    chksum[8];        char    linkflag;        char    linkname[NAMSIZ];

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -