This entry describes how to backup files -- that is, how to copy one or more selected files onto floppy disks. You should do this regularly to provide yourself with a spare copy of valuable files should your system suffer a catastrophe.
The strategy you adopt for backups will vary quite a bit, depending upon the medium onto which you back up your files: tapes or floppy disks. Floppy disks are inexpensive, but their limited capacity means that you have to plan carefully. Tapes are simpler to use than floppy disks, but are more expensive. The following sections describe first the strategies for backing up onto floppy disks; and then for backing up onto tapes.
Please note that the following descriptions assume that you are using a 5.25-inch, high-density floppy disks set in drive 0 (drive A). For a list of available floppy-disk devices, see the Lexicon entry for floppy disks.
The following describes how to use tar to back up onto floppy disks.
The first step is to prepare floppy disks to receive files. Insert a 5.25-inch floppy disk into drive 0, and then type the following command:
/etc/fdformat -v /dev/rfha0
The command fdformat formats the floppy disk, verifying that no media defects exist. You must perform this task of formatting a floppy disk before you use it the first time.
The next step is to create an archive of the files you wish to back up. Use the portable archive command tar to collect a mass of files into an archive on the floppy disks. For example, to archive all files in directory ssoouurrccee, use the following command:
tar cvf /dev/rfha0 source
The options ccvvff tell ttaarr to create an archive, run in verbose mode, and write the archive onto the device or into the file named in the next argument. //ddeevv//rrffhhaa00 names the floppy device onto which you wish to write the archive. Finally, ssoouurrccee is the directory whose files you wish to back up.
To perform a listing of the contents of the newly created archive, type
tar tvf /dev/rfha0
The options ttvvff tell ttaarr to list the contents of the archive, run in verbose mode, and read the archive from the device or file named in the next argument.
To extract several files from the archive, enter a command of the form
tar xvf /dev/rfha0 source/myfile 'source/*.c'
The options xxvvff tell ttaarr to extract or unarchive the specified files, run in verbose mode, and read the archive from the device or file named in the next argument. Note that the second file argument contains a ``wildcard'' character and thus must be quoted to prevent expansion by the shell.
For more information on how to use tar, see its entry in the Lexicon.
The following describes how to back up using gnucpio.
The COHERENT utility gnucpio performs mass dumps and restores of files using a universally recognized file format.
In this example, dumps are performed monthly, weekly, and daily. You should prepare at least three sets of floppy disks for the monthly saves, giving you three months of full backup. You will use the floppy disks in rotation, with the oldest always used next.
Once a month, you should dump the entire system.
Once a week, you should dump information in the system that is new or has been changed since the end of the previous week. You will need five sets of floppy disks, because some months have five weekends in them.
Finally, every day you should save information that has changed that day. For these dumps, you will need five sets of floppy disks: one for each working day. You may need extras in case of weekend work.
Label each set of disks carefully as _m_o_n_t_h_l_y, _w_e_e_k_l_y, or _d_a_i_l_y. Label the daily floppy disks ``Monday'' through ``Friday'', the weekly floppy disks ``Week 1'' through ``Week 5'', and the monthly floppy disks ``Month 1'' through ``Month 3''. When you perform the dump, write the date on the label.
The following gives a step-by-step description of how to use gnucpio to back up files. The next samples are given with the suggestion that your system has only one 5.25-inch floppy-disk drive.
/etc/wall
Please log off.
Time for file dump.
<ctrl-D>
who
cd /
find . -print | gnucpio -ocF /dev/rfha0
cd /
find . -newer cpio.weekly -print | gnucpio -ocF /dev/rfha0
touch cpio.weekly
cd /
find . -newer cpio.daily -print | gnucpio -ocF /dev/rfha0
touch cpio.daily
If you wish, you can back up only limited portions of your system. To do so, just name in your find command the directories you wish to back up. For example, to back up everything in your home directory and in /usr/lib, use the following command:
find $HOME /usr/lib -type f -newer cpio.daily -print | gnucpio -ocF /dev/rfha0
touch cpio.daily
When you determine the backup strategy you wish to use, you should save the appropriate commands into a script, to ensure that backups are run correctly every time.
The following describes how to restore files from floppy disks.
If you find that a file has been inadvertently destroyed, you can restore the information to disk from backup floppy disks.
To restore information from backups created with gnucpio or tar, you must first determine the date and time that the file was last known to have been modified. From this date, determine on which set of disks the file was last correctly dumped. Find the set of floppy disks labeled with that date, and insert into the floppy-disk drive the first one in the set. For example, if you wish to restore the file myfile, from a gnucpio archive, use the command:
gnucpio -icdvF /dev/rfha0 myfile
To retrieve myfile from a tar archive, use the command:
tar xvf /dev/rfha0 myfile
Both of these commands assume that the disks are high- density, 5.25-inch floppies in drive 0 (drive A). See the Lexicon article floppy disk for a table that shows which COHERENT device is associated with which size and density of disk, and which disk drive. You may have to insert more than one disk from the set of backups until you find the one that holds the file you want.
To back up an entire partition, do the following:
/etc/shutdown single 0
gtar -cvzf /dev/_t_a_p_e _d_i_r_e_c_t_o_r_y
gtar -xvzf /dev/rStp2 "v/fwb/myfile.c"
Note that the file will be written into a subdirectory of your current directory. For example, if your current directory is /v/fwb, then myfile.c will be restored into a file with the path name /v/fwb/v/fwb/myfile.c. This may be a little inconvenient, but is not nearly as inconvenient as having to create myfile.c by hand.
Suppose you have a directory named dir1, which contains files you want to backup. To back up all files in that directory onto a tape, insert a tape cartridge into the drive, then type:
gtar -cvf /dev/ft dir1
To verify that the contents of the tape match the original files, run gtar again in verification (``diff'') mode:
gtar -df /dev/ft
We strongly urge you to verify tapes after they have been written, especially with floppy-tape devices. If a tape fails this test, throw it away and build a new archive; otherwise, you may receive a nasty surprise when you try to restore a file from that tape. Do not be surprised if an otherwise sound tape fails after time: a tape does wear out after a number of uses.
To later extract the files from the tape, use
gtar -xf /dev/ft
To use data compression, the preceding commands can be used with the addition of gtar's option -z, as follows:
gtar -czvf /dev/ft dir1
gtar -dzf /dev/ft
gtar -xzf /dev/ft
To backup only selected files to tape, you could do the following:
find dir -type f -print | sort > Files
then manually edit the file Files so it contains only the names of the files you want to back up. Then use the command:
gtar -cv -T Files -f /dev/ft
The previous examples used /dev/ft, the device node that calls for the tape to be rewound when the device is closed. This is convenient if you are putting only one archive onto tape. To concatenate multiple archives on a single cartridge, use the no-rewind-on-close device. For example, suppose you have a second directory, dir2, and you want to back it up on the same tape, after an archive of dir1. The following commands accomplish this:
gtar -cvf /dev/nft dir1
gtar -cvf /dev/nft dir2
After each archive is written, the tape remains positioned at the end of the archive. To verify the contents of both archives, do the following:
# this command rewinds the tape:
tape rewind
# this command displays the contents of the first archive:
gtar -tvf /dev/nft
# this command displays the contents of the second archive:
gtar -tvf /dev/nft
If you make a note of the locations of archives as they are written, you can retrieve them later without having to read the preceding archives. For example:
# rewind the tape:
tape rewind
# write "dir1" archive at start of tape:
gtar -cvf /dev/nft dir1
# find current position of the tape:
tape tell
The command tape tell returns a string of the form:
Tape Is at Byte Offset 102400
Continuing:
# write "dir2" archive after "dir1":
gtar -cvf /dev/nft dir2
# read the current position:
tape tell
The second instance of tape tell returns a string of the form:
Tape Is at Byte Offset 235520
That is, it shows that the tape has advanced after the second archive was written onto it. At this point, the cartridge is removed, then reinserted into the tape drive at a later date:
tape seek 102400
gtar -tvf /dev/tape
The command tape seek moves the tape to the byte position 102400, i.e., the end of the first archive. This command assumes that you jotted down the position displayed by the command tape tell executed earlier. The command gtar then displays the contents of the second archive.