Creating an archive

The simplest backup you can do on your system is to duplicate the files individually using cp or pax.

For example, to duplicate a single file:

cp -t my_file backup_directory


echo my_file | pax -rw backup_directory

To back up an entire directory, type:

cp -Rt my_directory backup_directory


find my_directory -print | pax -rw backup_directory

To back up only certain files matching some criteria, use the find utility or other means of identifying the files to be backed up, and pipe the output to pax -rw, like this:

find my_directory -name '*.[ch]' | pax -rw backup_directory 

To combine individual files into a single archive, use tar or pax. These utilities take all the files that you give them and place them into one big contiguous file. You can use the same utilities to extract discrete files from the archives.

Note: Some filesystems can't support archives—or any other files—that are larger than 2 GB.

When you use pax as an archiver (pax -w mode), it writes tar-format archives. Your choice of which to use is based on the command-line syntax that works better for you, not the format of the archives, because the formats are identical. The pax utility was created as part of the POSIX standard to provide a consistent mechanism for archive exchange (pax stands for Portable Archive eXchange), thus avoiding conflict between variants of the tar utility that behave differently.

You can create archives of:

You can keep the archive on your local system, but we recommend that you keep a copy of it on a remote system; if the local system gets physically damaged, or the hard disk is corrupted, you'll lose a local archive.