Using tar to Back Up and Restore Files

You will find that this section on tar uses much of the same wording as in the following section on cpio. The two commands have similar functionality, and only some specific details and examples change the two sections. The tar and cpio sections are complete in themselves without complicated references to one another, but if you read them both, you’ll get a strong sense of déjà vu.

Backing Up a Directory Subtree

tar stands for tape archive utility because typical UNIX backups are done on a tape drive. tar can also back up to a disk or a disk file. This is an example of a basic tar command to back up one complete directory:

$ cd /usr/fred/projects
$ tar cvf /dev/XXX? .

First use cd to change to the directory ...

Get Practical UNIX now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.