DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH
 

(tar.info.gz) Dealing with Old Files

Info Catalog (tar.info.gz) Writing (tar.info.gz) Overwrite Old Files
 
 Options Controlling the Overwriting of Existing Files
 .....................................................
 
    When extracting files, if `tar' discovers that the extracted file
 already exists, it normally replaces the file by removing it before
 extracting it, to prevent confusion in the presence of hard or symbolic
 links.  (If the existing file is a symbolic link, it is removed, not
 followed.)  However, if a directory cannot be removed because it is
 nonempty, `tar' neither removes it nor modifies its ownership,
 permissions, or time stamps.
 
    To be more cautious and prevent existing files from being replaced,
 use the `--keep-old-files' (`-k') option.  It causes `tar' to refuse to
 replace or update a file that already exists, i.e., a file with the
 same name as an archive member prevents extraction of that archive
 member.  Instead, it reports an error.
 
    To be more aggressive about altering existing files, use the
 `--overwrite' option.  It causes `tar' to overwrite existing files and
 to follow existing symbolic links when extracting.  The
 `--overwrite-dir' option is somewhat more conservative than
 `--overwrite': it overwrites metadata (ownership, permission, etc.) for
 directories, but removes other files before extracting them.
 
    Some people argue that GNU `tar' should not hesitate to overwrite
 files with other files when extracting.  When extracting a `tar'
 archive, they expect to see a faithful copy of the state of the
 filesystem when the archive was created.  It is debatable that this
 would always be a proper behavior.  For example, suppose one has an
 archive in which `usr/local' is a link to `usr/local2'.  Since then,
 maybe the site removed the link and renamed the whole hierarchy from
 `/usr/local2' to `/usr/local'.  Such things happen all the time.  I
 guess it would not be welcome at all that GNU `tar' removes the whole
 hierarchy just to make room for the link to be reinstated (unless it
 _also_ simultaneously restores the full `/usr/local2', of course!  GNU
 `tar' is indeed able to remove a whole hierarchy to reestablish a
 symbolic link, for example, but _only if_ `--recursive-unlink' is
 specified to allow this behavior.  In any case, single files are
 silently removed.
 
    Finally, the `--unlink-first' (`-U') option can improve performance
 in some cases by causing `tar' to remove files unconditionally before
 extracting them.
 
Info Catalog (tar.info.gz) Writing (tar.info.gz) Overwrite Old Files
automatically generated byinfo2html