FIXME update, convert to wiki, add link to isohome

Backup With Tar

While I make regular backups of the home directories on the Computer Science Unix machines, there are times when you want to have your own copy of your account. There are several relatively painless ways to accomplish this task. I will describe one of them here. If you need my help, please ask. If you know of a way I could describe this process better please let me know so I can share it.

The process consists of making an archive file (one file that contains all your files - or at least the interesting ones) and then moving that file off of our system.

The heart of this process is the tar command. With this command, which originated as a Tape ARchive command (tar), you can take many files and directories and turn them in to one file. This one file can then be compressed and stored somewhere off our system (either on another computer, or on some form of media). At any point, some or all of the files can be restored, in their original positions (directories and directory hierarchy are preserved) and with their original permissions. We have the gnu tar program on our system as well as the version of tar distributed with the OS. The advantage to using gnu tar is that tar can do its own compression, which saves you a step. Files created in this way (with gnu tar doing its own compression) can be restored either by gnu tar or by using gunzip (gnu zip decompression) and any standard tar program.

Gnu tar is /usr/local/bin/tar and should be the first “tar” on your path. The remainder of this document will assume that you are using gnu tar.

For simplicity, if you would like to generate an ISO file of your entire home directory for simple CD burning, try using isohome.

The tricky bit is that you are going to create a tar file of your home directory in your home directory that does not contain the tar file itself. To do this use the exclude file option to tar, this allows you to give tar the name of a file which contains file names to ignore when creating the tar file.

For the purposes of the following examples, suppose that your home directory is “/home/tegorman” and that you are going to call your archive “my.CS.account.tar.gz”.

To make the exclude file, use any editor you like, just put one file or directory name on each line of the file and save it. For this example I will call the exclude file “/home/tegorman/exclude.list” and it contains following lines:


As you can see it lists the name of the backup archive file and also will exclude from the backup the Netscape cache (usually about 5 megs of stuff you don't need a backup of) and your desktop Trash folder. You can add any other directories or files you would like to exclude from the backup. (You can call this file anything you want to, just be sure you tell tar about it.)

With your exclude file saved you are now ready to run tar. Move up one level above your home directory, in this case to “/home”.

cd /home

Now issue the following tar command (be sure you are seeing the entire command in your browser, you may need to scroll to see it all):

tar czfX tegorman/my.CS.account.tar.gz tegorman/exclude.list tegorman

(The above command is all on one line)

Depending on how big your account is it could take awhile to finish, but when it does, there will be a file called “my.CS.account.tar.gz” in your home directory. This file is a copy of your entire directory (excluding the files in exclude.list).

Now that you have created a backup file of your account, using scp, you can copy the file to another system. You will most likely want to do the copy from the other system. Please consult the documentation for scp on that system. If you use a command line interface, the command will look something like this (remember in our example your account name is “tegorman” and the tar file is called “my.CS.account.tar.gz”):

scp  csbackup.tgz

The above will create a copy of the file on other system called csbackup.tgz.

From there it's up to you. Save it off on a zip drive, keep a copy on your personal machine, burn a CD, whatever you like.

Once you have copied your archive to another location, please remove the tar file from the CS machines. We do not have space to to keep a tar of each person's account on disk, that's why I do backups to tape! To remove the file, use the rm command:

rm /home/tegorman/my.CS.account.tar.gz

You can now sleep easier knowing that you have your own copy of all your files. Should the need arise, you can restore any or all of them on our or another system. Any Linux, MacOSX or other Unix system should support this, and additional versions of tar and gzip are available for earlier versions of MacOS and for DOS and Windows, so you don't even need a unix machine to have access to your files.

More information on tar is available in several formats and at several locations. Here are a few:

Tar help in //Unixhelp// This offers good basic tar help with examples. This is a good place to start, especially if you feel like this is all too complex. However, this source only documents standard Unix tar, not gnu tar which has more features. Still, it's a very good place to find out how tar works.Info pages for Gnu TarThese info pages offer all the detail you would ever need - but can be a bit overwhelming.Man page for tarUnix manual page format tar help. Concise help for Solaris Tar.

This page was written using emacs and psgml mode with an HTML 2 DTD. If you have any questions or comments about it, please send them to: No Soliciting

This page last was mucked with on 5/9/02