Go to the previous, next section.

Adding to an Existing Archive

(This message will disappear, once this node revised.)

The `--append' (`-r') option will case tar to add new files to an existing archive. It interprets file names and member names in exactly the same manner as `--create' (`-c'). Nothing happens if you don't list any names.

This option never deletes members. If a new member is added under the same name as an existing member, then both will be in the archive, with the new member after the old one. For information on how this affects reading the archive,

FIXME: ref Multiple Members with the Same Name
.

This operation cannot be performed on some tape drives, unfortunately, due to deficiencies in the formats thoes tape drives use.

To add files to an archive, use `--append' (`-r'). The archive to be added to must already exist and be in proper archive format (which normally means it was created previously using tar). If the archive was created with a different block size than now specified, tar will report an error (

FIXME: pxref Blocking Factor
). If the archive is not a valid tar archive, the results will be unpredictable. You cannot add files to a compressed archive, however you can add files to the last volume of a multi-volume archive.

FIXME: xref Matching Format Parameters
.

The following example adds the file `shemp' to the archive `stooges' created above:

tar --append --file=stooges shemp

You must specify the files to be added; there is no default.

`--update' (`-u') acts like `--append' (`-r'), but does not add files to the archive if there is already a file entry with that name in the archive that has the same modification time.

Both `--update' (`-u') and `--append' (`-r') work by adding to the end of the archive. When you extract a file from the archive, only the version stored last will wind up in the file system. Because `--extract' (`-x') extracts files from an archive in sequence, and overwrites files with the same name in the file system, if a file name appears more than once in an archive the last version of the file will overwrite the previous versions which have just been extracted. You should avoid storing older versions of a file later in the archive.

Note: `--update' (`-u') is not suitable for performing backups, because it doesn't change directory content entries, and because it lengthens the archive every time it is used.

FIXME: xref to scripted backup, listed incremental, for info on backups.

Go to the previous, next section.