Unix Information - Backing Up

by D.W. Hyatt

Backing Up Files

Since catestrophic errors happen within our computer lab from time to time, we recommend all users to save important files to disk occasionally.

Tape Archive   -   tar

The tar command is frequently used to save entire directory structures into an archive. To create a backup file of a firectory type tar followed by argument c for create, v for verbose so that we can see what it is saving, and f to indicate that the output is going to a file. After that, the user also adds the name of the backup file followed by the directory to be saved. Here is the full command.

tar   -cvf   backup.tar   dir-name


To untar, just type tar with the argument x instead of c for extract.

tar   -xvf   backup.tar


It will create the directory as well as any subdirectories in the restore process.


Compressing Files   -   gzip

To compress a file, the gzip compression utility is often a useful tool. The following will compress the backup file produced above to a compressed version. The result will be a file called backup.tar.gzshowing that it has been compressed with the gzip utility.

gzip   backup.tar


To uncompress, just type gunzip followed by the file name.

gunzip   backup.tar.gz


Since it is often true that people wish to archive directories and compress the resultant files to save space, the tar command with the z argument also compresses using gzip, accomplishing both tasks. The following creates a compressed archive file of the specified directory.

tar   -cvfz   backup.tar.gz   dir-name


To uncompress, just type

tar   -xvfz   backup.tar.gz



Saving to a Floppy

Files can be copied directly to a floppy disk on the A-Drive by using the mcopy command.

mcopy   backup.tar.gz   a:


Howver, it is also possible to use the tar command to save directy to the A-Drive, using the following command. This command also uses the M argument in case the file is too big for one disk and must be spread out over Multiple Volumes, or several floppy disks.

tar   -cvfzM   /dev/fd0/backup.tar.gz   dir-name


To uncompress, just use the extract version. Just be sure to put the disks into the A-Drive in the proper order.

tar   -xvfzM   /dev/fd0/backup.tar.gz