Archiving Files |
|||||||||||||||||||||||||||||||
|
This section describes how to store the files in your directory to either 3.5" diskettes or DDS's (Digital Data Storage) and then how to retrieve them from one of these sources.
To archive your files from one of the College of Engineering Workstation machines, you will need either:
| |||||||||||||||||||||||||||||||
| Where to Archive Files |
You can archive files to 3.5" HD diskettes using any Sun SPARCstation. All of these have 3.5" drives available.
You can archive files using 4mm DDS's at most lab sites. | ||||||||||||||||||||||||||||||
Archiving onto a DOS Disk |
|||||||||||||||||||||||||||||||
|
Sun Workstations |
| ||||||||||||||||||||||||||||||
|
|
To format a DOS diskette on the Suns, insert the floppy into the drive and type:
The first thing that must be done before you can access files on a DOS diskette is that you must mount the diskette as a filesystem. To do this, insert the diskette into the drive and type:
Assuming the disk is in DOS format, you should get the message:
eject floppy when done.
Copying files from UNIX to a DOS diskette To copy a binary file from the workstation to the floppy, simply use the regular Unix cp command, as in:
This copies the file myfile in the current directory to the DOS file mydile. Note that you must preface the DOS filename with /floppy/ - this is because the DOS disk is mounted at that point in the filesystem. To copy an ASCII file from the workstation to the floppy, you need to use a special command:
This converts the Unix formatted file to DOS format and copies it to the floppy. For further information type man unix2dos at any unix prompt. Copying files from a DOS diskette to UNIX To copy a binary file from the floppy to the workstation, simply use the regular Unix cp command, as in:
This copies the file myfile from the DOS diskette (note the /floppy that precedes the name - this is because the DOS disk is mounted at that point in the filesystem) to the current directory. To copy an ASCII file from the floppy to the workstation, you need to use the special command:
This converts the DOS-formatted file to Unix format and copies it from the floppy to the current directory. For further information type man dos2unix at any unix prompt. Deleting files from a DOS diskette To delete a file from a DOS diskette, simply use the Unix rm command:
This command would remove the file myfile from the diskette. Listing files and directories on a DOS diskette To get a directory listing of a DOS diskette, simply use the ls command, as in:
This would list all files in the top-level directory of the DOS diskette. See the man page for the ls command for more options. When you are done working with the DOS diskette, you must unmount and eject it. To do this, use the command:
This will flush all remaining information to the disk, unmount it, and eject it.
Removing a DOS diskette from a workstation
Sparc20
Ultra10 | ||||||||||||||||||||||||||||||
|
Archiving Using "tar" |
The tar (Tape ARchiver) utility is a standard prmgram on almost all Unix operating systems. All College of Engineering Workstations have this utility. With tar, it is possible to archive not only individual files, but also entire directory trees. Because the tar format is so standard, it is almost guaranteed that you will be able to use the data you have archived using it at any site in the world. tar can also be used to create archives on a variety of different output devices, such as floppy disk, tape, and even another file. The section below describes the general usage of the tar utility, and the sections following it describe in more detail the various output options available on EWS machines. The general format for creating a tar archive is:
The filespec parameter can be one or more files or directories you wish to archive. If you specify a file (you can include wildcard characters), then the matching file(s) is (are) copied to the archive. If you specify a directory, then all files an d subdirectories of that directory are archived. Hence, it is possible to archive an entire directory tree. For example, to copy the files data1.txt, a.out, and program.c to an archive file called program.tar, you would type:
This command would create a file in the current directory called program.tar which itself would contain the three listed files. Suppose you wished to archive a subdirectory of your home directory called text to the 3.5" disk drive on an IBM RS/6000. Here's what you would type:
Note that since Unix devices are represented as files, we can tar to them just as we tar to a regular file. Here's another example: Suppose you want to archive all files in your directory with the extension .c to an archive file called programs.tar. Here you would type:
Viewing the contents of an archive There may be times when you will want to see what is stored in a tar archive without actually restoring the files from that archive. The general form for doing this is:
For example, suppose you would like to find out what files are archived in the file utils.tar in the current directory. You would type:
Perhaps you archived your files on a 3.5" floppy disk several months back and now can't remember what you put there. Here is what you would type to list these files back (IBM RS/6000):
Suppose you are looking for the file resume.tex in the archive file texstuff.tar. Here's how you could do it:
Restoring files from a "tar" archive The general format for restoring files from a tar archive is:
Please note that when you archive files using a directory specifier, as opposed to just simple filenames, tar records the directory along with the filename in the archive. Hence, when you go to restore, tar will put the files in the same dir ectory they were restored from, even if it has to create it. Usually, it is a good idea to first list the contents of the archive before you restore it in order to make sure that you are restoring it in the proper directory. For example, suppose you wish to restore all the files you archived onto a 3.5" disk on one of the IBM machines. The files were archived using the command tar cvf /dev/fdO papers, where papers was a subdirectory of the directory you were in when you typed the above command. To restore these files back into a subdirectory of the current directory called papers type:
To restore the files static.h from the archive file classwork.tar you would type:
To restore only the usr/include directory (including files and subdirectories) from the archive file /tmp/compiler.tar use:
For more information about the tar command, see the man pages on one of the EWS systems. | ||||||||||||||||||||||||||||||
|
Although it is possible, as outlined in an earlier section, to store your files on 3.5" diskettes in MS-DOS format, you may find it more desirable to store them in tar format, especially if you never intend to use them on an MS-DOS system. Before you can use a 3.5" diskette with the tar command, you must format it. Be sure you have a 3.5" HD floppy diskette inserted in the drive. If you are using a SUN workstation type fdformat. When the formatting is complete, your disk is ready to be used with tar. The archive name you should use for SUN workstations whenaccessing the floppy drive is:
You may be wondering how you can put more than one archive on a floppy disk. Well, this is not easy. Typically, you will only put one tar archive per floppy disk, as it is not possible to divide up the floppy into multiple archives. tar does provide means for extending an existing archive, so if you wish to use that, see the man pages. |
|||||||||||||||||||||||||||||||
|
4mm DDS (Digital Data Storage) are usable on all platforms. They are capable of storing a very large amount of data - up to 2 gigabytes. Although there is nothing wrong with using them to store the contents of your directory, it is unlikely that you will ever need the full capacity of one of these tapes. Just like 3.5" diskettes, these tapes provide some difficulty when trying to use them with multiple tar archives. Fortunately, there is a way to store more than one archive on these tapes! Rewinding and non-rewinding devices Almost any system that has a tape drive attached has more than one device name for accessing that drive. The first is usually a rewinding device, and the other is a non-rewinding device. A rewinding device always rewinds the tape after you are done accessing it. For example if one were to store an archive using tar to a rewinding device, the tape would automatically rewind as soon as the tar command had completed. A non-rewinding device does not automatically rewind the tape after you are done accessing it. Rather, the tape is left at the position you last accessed. If you ever hope to store more than one archive on a tape, you will need to be familiar with and use the non-rewinding device when you access the tape drive. On Sun platforms, the names are:
On IBM platforms, the names are:
In order to maintain multiple archives on a single tape, you need to know how to move the tape backwards and forwards among the archives. To do this, we will use the mt command. The general format for this command is:
where command if one of the following:
For example, to skip over the first archive on the tape in order to be able to read the second, use:
To rewind the tape, use:
Extended examples of using multilple archives on DDS This example will cover writing several archives to tape, then moving the tape back and forth, then accessing them. Let's assume that the user has three directories called bin, text, and source that he wants to archive separately. First, he inserts the tape into the drive (this is pretty obvious!). The tape should be rewound, but just to make sure, he types:
Now he is ready to archive his three directories. Here we go:
Since the non-rewinding device was chosen each time, each archive was written immediately after the one preceding it. Before he leaves, he rewinds the tape (you should ALWAYS do this).
Several days later our user, due to some careless use of the rm -r command, needs to restore the entire text directory from his archive tape. Furthermore, he decides that he had better also archive his lib directory, just in case he should accidentally delete anything. First, he inserts the tape into the drive. This time we know it is rewound, so there is no need to rewind it. The first action he will do is restore the text directory, which is the second archive on the tape. Since the tape is rewound, it is ready to read the first archive, which is the bin directory. Hence, we need to skip over this archive to reach the second. Here's what he types:
This instructs the computer to skip over one archive. Now the tape is positioned to read the second archive.
This extracts the second archive from the tape, leaving the tape positioned at the beginning of the third archive. Now our user wants to store his lib directory on the tape, so he needs to space over the third archive to the end of the tape. Again, we skip over one file:
Now we are at the end of the tape, so he can archive the lib directory using:
Now the tape contains four archives and it is positioned at the end-of-tape. Our user now does some file work, and makes another mistake! He has just wiped out his source directory! Since he has not removed the tape from the drive, he decides to immediately restore it. Remember, the tape is currently at the end of the fourth archive. The source archive is the third archive on the tape. Hence, to position the tape at its beginning, he must move the tape back two archives - one to skip back over the fourth, and one more to skip over the third.
Now the tape is positioned at the beginning of the third archive. To restore it, he types:
Deciding that he has done enough damage for the day, our user thinks he should quit, so he rewinds the tape.
Pushing the button on the front of the tape drive releases the tape. |
|||||||||||||||||||||||||||||||
|
To save space on your account, you may want to compress, or "zip-up" some of your files. gzip
and gunzip make this a relatively easy task. Simply type "gzip" and the file name to compress a file:
And simply type "gunzip" and the file name to decompress the file into usable form:
For more information and a list of tags to these commands see the UNIX manual page for gzip and gunzip:
|