Archiving files (tar command)

The archive backup method is used for a copy of one or more files, or an entire database that is saved for future reference, historical purposes, or for recovery if the original data is damaged or lost.

Usually, an archive is used when that specific data is removed from the system.

Use the tar command to write files to or retrieve files from an archive storage. The tar command looks for archives on the default device (usually tape), unless you specify another device.

When writing to an archive, the tar command uses a temporary file (the /tmp/tar* file) and maintains in memory a table of files with several links. You receive an error message if the tar command cannot create the temporary file or if there is not enough memory available to hold the link tables.

See the following examples:
  • To write the file1 and file2 files to a new archive on the default tape drive, type the following:
    tar -c file1 file2
  • To extract all files in the /tmp directory from the archive file on the /dev/rmt2 tape device and use the time of extraction as the modification time, type the following:
    tar -xm -f/dev/rmt2 /tmp
  • To display the names of the files in the out.tar disk archive file from the current directory, type the following:
    tar -vtf out.tar

See the tar command in the Commands Reference, Volume 5 for more information and the complete syntax.