home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Hacker Chronicles 2
/
HACKER2.BIN
/
076.COLUM04.TXT
< prev
next >
Wrap
Text File
|
1993-07-30
|
21KB
|
475 lines
Backing Up is Hard to Do
By Ken Johnson, Chicago Computer Society
"Thou Shalt Back Up." This is one of the cardinal rules in
computing: making duplicate copies of important files and
storing them in a safe place. Unfortunately, backing up is often
like flossing or eating broccoli -- something you know is good
for you but that you don't do (or don't do often enough)!
However, backing up doesn't have to be a chore. We'll look at
some approaches and alternatives that make backing up easier.
This article will focus on "software" methods that backup to
floppy disks. In terms of speed and power, floppy backup can't
compete with backup hardware such as tape drives. But backup
hardware is expensive and may require some technical expertise to
get started. We'll look at using software (DOS or other
programs) to get you started backing up right away.
First, you need to develop a backup strategy. When developing
the strategy that best suits your needs, consider the following
points:
1. You don't have to back up the entire hard disk every time.
You should do a full backup when starting out. But you can do
incremental backups that will only backup those files that have
changed. DOS' BACKUP and XCOPY commands let you select only
changed files; commercial backup utilities also have this
capability. By subsetting only the changed files your backups
are less time consuming, and you're more likely to do them.
2. Backup data files, not necessarily program files. Chances
are what is most important to you is your data, not the programs
that created that data. The program files can always be restored
from the original disks (the ones they told you to put in a safe
place, remember?). For example, I keep a lot of CCS information
in Paradox databases. I back up those files regularly, but I am
less concerned with backing up the actual Paradox system files.
Those I can always copy back from the original disks.
To make it easier to back up data files, you probably will want
to keep them separate from the program files. This is easy to do
on a hard disk -- simply create separate subdirectories.
Depending on the number and size of files in these
subdirectories, you may be able to do a simple COPY *.* to backup
the entire subdirectory to a floppy disk.
3. Don't forget the floppies! Your backup strategy also should
include data files kept on floppy disks. Too often we associate
"backing up" only with hard drives. If you keep important
information on floppies, they also must be backup up. Floppies
are more susceptible to damage because they are outside of the
computer and more exposed to dangerous elements: magnetic
fields, spilled coffee, children looking for frisbees, etc.
Luckily, backing up floppies can be easy. Just use DOS' DISKCOPY
command for a quick and simple backup. DISKCOPY makes an exact
duplicate of the disk, copying all files (including hidden and
system files), the volume label, and duplicating any directory
structure.
You can use DISKCOPY even if you have only one drive. If you
specify one drive or no drive with the command, the disk in that
drive (or in the default drive) is copied to another disk in the
same drive. You'll be prompted to swap disks.
4. Use batch files to automate backing up (however you choose to
do it). Anything you can do to automate the process of backing
up is good, because it means that you are more likely to do it.
For example, let's say that you have your Wordperfect data files
segregated into a separate subdirectory on your hard drive called
WPDATA. You can create a batch file to use WordPerfect, then
copy all the files in WPDATA to a floppy disk in the A: drive:
ECHO OFF
CD WPDATA
C:\WP51\WP
ECHO Place the WordPerfect backup disk in Drive A:
ECHO Press Ctrl-Break if you don't want to back up right now
PAUSE
XCOPY C:\WPDATA\*.* A:
"Echo Off" suppresses the display of the DOS commands as they
execute. The next two lines change to the WPDATA subdirectory
and load WordPerfect (which is in a subdirectory called WP51).
After you exit WordPerfect the Echo commands tell you that a
backup is going to take place and pauses execution until you
press a key. This allows you time to put in the disk. (Notice
that you can Control-Break to stop the batch file at this point
and thus not do the backup). Finally all the files in the WPDATA
subdirectory are copied to the disk in the A: drive using XCOPY.
XCOPY is faster than COPY because it uses all available RAM for
the copy.
Now lets take a look at some approaches to backing up your files.
Using DOS BACKUP and RESTORE
The first, but perhaps the least attractive approach to backing
up your files is using DOS' own BACKUP and RESTORE. These DOS
commands are probably what put most people off backing up. They
are cumbersome to use and have annoying restrictions (especially
in DOS versions before 3.3). Many software vendors make a good
living by selling programs that keep you from having to deal with
BACKUP and RESTORE. One "advantage" of BACKUP/RESTORE though is
that they are free and easily accessible on your hard drive.
The BACKUP command copies files in a special format, and large
files can be split over multiple floppy disks. Because of the
special format, files can only be retrieved and restored with the
RESTORE command.
The BACKUP command syntax is:
BACKUP [source_drive:][filespec] destination_drive: [/S] [/M]
[/A] [/D]
DOS 3.3 added these switches: [/T] [/F] [/L]
/S -- backs up files from the selected and all child
subdirectories.
/M -- backs up only those files modified since they were last
backed up.
/A -- adds backed up files to an existing backup diskette.
/D:mm-dd-yy -- backs up files created or modified on or after the
date specified.
/T:hh:mm:ss -- used with /D to backup files on or after the time
specified.
/F -- formats the destination disk if it is not already
formatted.
/L[:filespec] -- creates a log file that lists the backed up
files. If a filespec is not specified, then a file called
BACKUP.LOG is created in the root directory. If the log file
exists, new entries are added to the end.
Some examples:
BACKUP C:\*.* A: /S
-- this does a complete backup of all files on the hard disk C:
to floppy disks in A:.
BACKUP C:\*.WK1 A: /S /M
-- backs up all files in all directories (/S) with an extension
of .WK1 that have been changed since the last time they were
backed up (/M).
BACKUP C:\*.* A: /S /D:01-01-91 /L:C:\BKUP91.LOG
-- backs up all files on C: created or modified on or after
January 1, 1991. The file c:\BKUP91.LOG will contain a list of
the files backed up.
The RESTORE command syntax is:
RESTORE source_drive [target_filespec] [/S] [/P]
DOS 3.3 added these switches: [/M] [/N] [/B] [/A] [/E] [/L]
You must specify the source drive (the floppy drive). The
"target" is the original filespec, including the full path, from
which the file was backed up. It may include wildcards.
/S -- restores all files that match the target filespec,
including all files in child subdirectories.
/P -- prompts to make sure you want to restore (overwrite) a file
that has been changed since it was backed up or files marked
Read-Only.
/M -- restores only files modified or deleted since the last
backup.
/N -- restores only files that do not exist on the target; in
other words will not overwrite any files.
/B:mm-dd-yy -- restore files modified on or before the specified
date.
/A:mm-dd-yy -- restores files modified on or after the specified
date.
/E:hh:mm:ss -- restores files modified at or earlier than the
specified time.
/L:hh:mm:ss -- restores files modified at or later than the
specified time.
Some examples:
RESTORE A: C:\*.* /S
-- all files backed up are restored from the disks in drive A:.
You will be prompted to insert the backup diskettes in sequence.
RESTORE A: C:\DBASE\*.DBF
-- all files with an extension of .DBF which were originally
backed up from the \DBASE subdirectory will be read from drive A:
and written to the \DBASE directory of drive C:. If that
directory doesn't exist on C:, it will be created.
RESTORE A: C:\*.* /S /P /A:01-01-91
-- restores all files modified or deleted after January 1, 1991.
You will be prompted before any files on C: that have been
changed since the backup, or are marked read-only, are restored.
BACKUP and RESTORE changed in DOS 3.3 to make them a little more
user friendly. BACKUP can now format disks while backing up. In
version before 3.3 you had to make sure you had enough formatted
disks before starting. If you ran out of formatted disks you had
to abort and run BACKUP again. In DOS 3.3 you tell BACKUP to
format with the /F parameter; in DOS 4.0 BACKUP will
automatically format the floppy disks if necessary.
BACKUP in DOS 3.3 also works faster and more efficiently than
older versions by combining small files into one large file. It
also creates a control file to tell RESTORE how to take this
large file apart and restore it properly. BACKUP also can create
a log to tell you where your files are on the backup disks.
RESTORE in DOS 3.3 lets you restore files that have changed or
have been deleted since the backup, or files no longer on the
hard disk. You also can restore based on date and time. Another
change in DOS 3.3 is that RESTORE will not restore the DOS system
files IBMBIO.COM, IBMDOS.COM (or their generic counterparts), and
COMMAND.COM. This is a plus, since it prevents you from
inadvertently restoring the wrong version of DOS. To complete
the restore you'll need to use the SYS command to put IBMBIO.COM
and IBMDOS.COM back on your hard disk, and then copy COMMAND.COM
over.
If you are using a version of DOS before 3.3, you may want use
the /P switch when doing a restore. This will prompt you before
files marked read-only are restored. You can answer NO for
IBMBIO.COM and IBMDOS.COM, then use SYS to copy these files over
from your original DOS disks.
As you can see, BACKUP and RESTORE aren't the easiest things in
the world to use. If you don't want expense of buying a backup
utility but still want to stay away from BACKUP/RESTORE, consider
using XCOPY as an alternative.
Using XCOPY as an alternative to BACKUP
If you are using DOS 3.3 or 4.0, XCOPY is a friendlier
alternative to DOS' BACKUP command. Not only is it much faster,
but copied files can be restored with the COPY command (in other
words, you don't have to mess around with RESTORE).
There are a couple of things to keep in mind when backing up with
XCOPY. XCOPY cannot copy files larger than a single diskette
(BACKUP is the only DOS choice then). It will not copy hidden
files. XCOPY does not overwrite files on the target diskette, so
the disks need to be formatted and empty. Finally, if you want
to backup all files, you need to use ATTRIB to set the archive
attribute on for all files before starting XCOPY.
The syntax for XCOPY is:
XCOPY d:source_filespec d:target_filespec [/S] [/E]
[/D:mm-dd-yy] [/A or /M] [/P] [/W] [/V]
/S -- copies files in child subdirectories as well as the
specified directory.
/E -- creates empty directories on the target, even if no files
are copied into those directories.
/D:mm-dd-yy -- copies only those files with a modified on or
after the date specified.
/A -- copies only those files with the archive attribute turned
on. This indicates a file that has been modified.
/M -- does the same thing as /A, but resets the archive attribute
after the copy. You can use either /A or /M, but not both.
/P -- prompts you before each file is copied.
/W -- waits for you to insert a disk into the source.
/V -- files are verified as they are copied.
When using XCOPY for a backup, you will need to use the /M switch
and reexecute the command as the disks fill. When XCOPY fills a
disk, it will stop with a "disk full" message. Repeat the
command, filling disks until all files have been backup up.
(Remember that /M turns the archive attribute off after a file is
copied. Therefore when you reexecute XCOPY files already copied
are ignored).
It is easiest to do an XCOPY backup with a batch file. In DOS
3.3 XCOPY will set ERRORLEVEL to 4 for a "disk full" error. You
can check for the ERRORLEVEL then loop back through the batch
file:
REM XCOPY Backup Batch File, DOS 3.3 only
@ECHO OFF
CLS
ECHO -- XCOPY full backup of C: drive --
ATTRIB +A C:\*.* /S
:loop
ECHO Insert blank, formatted disk in A: drive
PAUSE
XCOPY C:\*.* A: /S/M
IF ERRORLEVEL 4 GOTO loop
ECHO -- All Done --
Let's take a closer look at this batch file. The ATTRIB command
turns on the archive attribute for all files on the C: drive.
The ECHO and PAUSE tell you to insert a new disk and press a key
to continue. XCOPY copies all files with the archive attribute
on to the A: drive, and turning the archive attribute off as the
copy is done. When the disk in A: fills, XCOPY ends with an
ERRORLEVEL of 4. This causes the batch file to loop back to the
ECHO and PAUSE commands, then reexecute XCOPY. Since the archive
attribute has been turned off for files already copied, those
files are ignored on each subsequent time through the batch file.
When all files have been copied, the batch file ends with the "--
All Done --" message.
Unfortunately, you can't use this batch file with DOS 4.0. In
DOS 4.0 XCOPY no longer sets an ERRORLEVEL code when the disk
fills. You can still use a batch file, but you have to stop the
batch program manually:
REM XCOPY Backup Batch File, DOS 4.0 only
@ECHO OFF
CLS
ECHO -- XCOPY full backup of C: drive --
ATTRIB +A C:\*.* /S
:loop
ECHO Insert blank, formatted disk in A: drive
ECHO or press Ctrl-Break if done . . .
PAUSE
XCOPY C:\*.* A: /S/M
GOTO loop
You'll notice that instead of checking ERRORLEVEL, this batch
file does an unconditional loop (and will continue to loop
indefinitely). You'll have to monitor the XCOPY and manually
break out of the backup with Ctrl-Break.
Using PKZIP/PKUNZIP to Backup and Restore
This is a personal favorite of many users. PKZIP is a shareware
program from PKWARE that compresses multiple files into a single
"ZIP" file. Not only is storage space reduced, but the single
ZIP file makes file group identification and transportation
easier. This is why zipped files are so popular on bulletin
board systems.
Of course, the compressed files are not useable in that form.
You use the companion program PKUNZIP to uncompress or extract
the compressed files. PKUNZIP also can selectively extract
individual files, display the files on screen for viewing, or
print files to the printer.
The basic command syntax for PKZIP is:
PKZIP [options] zipfile [files . . .]
zipfile -- is the name (and location) you give the ZIP file. The
default extension is .ZIP.
files -- is the names of the files to compress; the wildcards *
and ? can be used.
PKZIP has a number of options that can be specified when creating
the ZIP file. See the PKZIP documentation for a full
description. Among the options useful for a PKZIP backup are:
-a -- adds files to new or existing ZIP file; same named files
will overwrite those already in the ZIP file.
-u -- updates an existing ZIP file with files only if they don't
exist in the ZIP file or if they have a date later than same
named files already in the ZIP file.
-r -- recurse through specified subdirectories and all child
subdirectories.
-wHS -- includes hidden (H) and system (S) files in the ZIP file.
At present, PKZIP does not can not create a single ZIP file which
spans multiple disks. You'll need to do selective file backups
using PKZIP, ensuring that each compressed file will fit on one
floppy. If you have your data files organized into
subdirectories as suggested above, PKZIP can easily be used to
backup individual subdirectories into separate ZIP files. Batch
files are especially useful for this.
For example, I prepare my training materials in WordPerfect,
saving them into a subdirectory called \TRAINING. I have created
a batch file that will start WordPerfect in that subdirectory,
then zip all the files when done:
ECHO OFF
CD TRAINING
C:\WP51\WP
ECHO Insert backup disk in drive A:
ECHO Press Ctrl-Break to stop before backup
PAUSE
PKZIP -u -wH A:TRAIN.ZIP C:\TRAINING\*.*
ECHO *** ALL DONE ***
This file updates the zip file on the A: drive called TRAIN.ZIP
with new and changed files from my \TRAINING subdirectory.
Notice that I use the -wH option to include hidden files. I use
a utility program that lets me give 60 character filenames to my
files, and it creates a hidden "library" file in the subdirectory
that I need to include in the ZIP file.
You could create similar batch files for each application you
work with regularly, backing up each data subdirectory after
using the application program. Once set up, it's so easy that
you will have no excuse not to backup!
Using a Backup Software Program
Probably the easiest (if most expensive) backup strategy is to
buy a backup software utility. These programs generally list for
under $150, with "street prices" lower. Backup utilities tend to
be simple to learn and use, with a menu-driven interface for both
backing up and restoring. They are capable of some level of
configuration, which allows you to save customized backup "sets"
for repeated use. Most can format disks on the fly. Many
support a mouse for added convenience.
Many backup utilities also offer as data compression, which
minimizes the number of disks you have to use. They also use the
dual Direct Memory Access (DMA) mode for efficiency. This mode
allows the computer to read from your hard disk and write to the
floppy disk simultaneously, thus making backups much faster.
The most popular backup utilities are probably Fastback Plus from
Fifth Generation Systems, Norton Backup from Symantec Corp., and
PC Tools Deluxe/PC Backup from Central Point Software. An
October 15, 1990 Product Comparison by InfoWorld rated these the
top three backup utilities of the seven tested.
Conclusion
Backing up doesn't have to be a chore. You need to give serious
thought to developing a backup strategy to deal with the real
possibility of damaged disks and lost data. You might think that
your hard disk won't crash and that you'll never encounter a
destructive virus. But also remember that backups can help you
recover from small disasters like static electricity scrambling a
file or your fingers typing DEL instead of DIR.
Using DOS' BACKUP and RESTORE can be intimidating and not
entirely successful. I've tried to present some approaches to
backing up that can make it easier to do on a regular basis --
segregating data files in separate subdirectories; using XCOPY or
PKZIP; automating backup with batch files; buying backup utility
programs.
Whatever method you might use, I hope you will develop a backup
strategy, put it in place, and do regular backups. Remember,
there are two kinds of computer users: those who have had disk
crashes and those who haven't had disk crashes YET. Now if I can
just get you to eat your broccoli . . . .