Go to the first, previous, next, last section, table of contents.


Backup options

GNU tar offers options for making backups of files before writing new versions. These options control the details of these backups. They may apply to the archive itself before it is created or rewritten, as well as individual extracted members. Other GNU programs (cp, install, ln, and mv, for example) offer similar options.

Backup options may prove unexpectedly useful when extracting archives containing many members having identical name, or when extracting archives on systems having file name limitations, making different members appear has having similar names through the side-effect of name truncation. (This is true only if we have a good scheme for truncated backup names, which I'm not sure at all: I suspect work is needed in this area.) When any existing file is backed up before being overwritten by extraction, then clashing files are automatically be renamed to be unique, and the true name is kept for only the last file of a series of clashing files. By using verbose mode, users may track exactly what happens.

At the detail level, some decisions are still experimental, and may change in the future, we are waiting comments from our users. So, please do not learn to depend blindly on the details of the backup features. For example, currently, directories themselves are never renamed through using these options, so, extracting a file over a directory still has good chances to fail. Also, backup options apply to created archives, not only to extracted members. For created archives, backups will not be attempted when the archive is a block or character device, or when it refers to a remote file.

For the sake of simplicity and efficiency, backups are made by renaming old files prior to creation or extraction, and not by copying. The original name is restored if the file creation fails. If a failure occurs after a partial extraction of a file, both the backup and the partially extracted file are kept.

`--backup'
Make backups of files that are about to be overwritten or removed. Without this option, the original versions are destroyed.
`--suffix=suffix'
Append suffix to each backup file made with `-b'. If this option is not specified, the value of the SIMPLE_BACKUP_SUFFIX environment variable is used. And if SIMPLE_BACKUP_SUFFIX is not set, the default is `~', just as in Emacs.
`--version-control=method'
Use method to determine the type of backups made with --backup. If this option is not specified, the value of the VERSION_CONTROL environment variable is used. And if VERSION_CONTROL is not set, the default backup type is `existing'. This option corresponds to the Emacs variable `version-control'; the same values for method are accepted as in Emacs. This options also more descriptive name. The valid methods (unique abbreviations are accepted):
`t'
`numbered'
Always make numbered backups.
`nil'
`existing'
Make numbered backups of files that already have them, simple backups of the others.
`never'
`simple'
Always make simple backups.

Some people express the desire to always use the op-backup option, by defining some kind of alias or script. This is not as easy as one may thing, due to the fact old style options should appear first and consume arguments a bit inpredictably for an alias or script. But, if you are ready to give up using old style options, you may resort to using something like (a Bourne shell function here):

tar () { /usr/local/bin/tar --backup $*; }


Go to the first, previous, next, last section, table of contents.