From: HDK@psuvm.psu.edu (H. D. Knoble)
Newsgroups: psu.comp.micro,comp.sys.ibm.pc.misc
Subject: PKZIP/DOS BACKUP - a simple backup procedure
Date: 7 Oct 92 13:09:44 GMT
Organization: Penn State University

As it turns out, DOS (4.0 and 5.0 at least) BACKUP command tries to
compress a bit the files it's backing up. If, however, the file is already
highly compressed, e.g., a PKZIP (by Phil Katz) file, then DOS BACKUP will
not change one bit in the file when it creates BACKUP.001, BACKUP.002, ... ,
except for splitting across diskette if necessary. Thus if one uses PKZIP
indexed backup (by providing PKZIP with a file that contains only those
filespecs that you wish to PKZIP) and PKZIP creates a ZIP file that BACKUP
will backup to one diskette, then the file BACKUP.001 would in fact be
also a ZIP file; e.g., PKUNZIP -v A:\BACKUP.001 | MORE  will display its
contents.

Because so many people recently seem to be suffering the loss of personal
data (versus re-installable files of a package they may use to create that
personal data) I offer a simple code and documentation here, say
ZBACKUP.BAT and ZBACKUP.HLP, to help some of you address this kind of
painful experience.  Unlike PSU mainframe computers, each person using a
microcomputer is responsible for the integrity of their own personal
files.  Given an ASCII index file of DOS filespecs, ZBACKUP.INX, that you
create, the actual code (including taking a snap-shot of DIR C:\*.*)
amounts to four four DOS commands like (assuming enough space on C: to
hold the zip file):

DIR C:\ > C:\C-Disk.DIR
PKZIP -a -P -J -w -z C:\ZBACKUP.ZIP C:\C-Disk.DIR @C:\ZBACKUP.INX
BACKUP C:\ZBACKUP.ZIP A:
ERASE C:\C-DISK.DIR

Including documentation, some integrity checks, etc.  the files, these
four commands are implemented in ZBACKUP.BAT which is documented in
ZBACKUP.HLP; an example of ZBACKUP.INX (the index file unique to each
unique person's "critical" files) also follows.  Each file appears below
and is separated by a line of dashes (---'s).  From PSUVM you can save
this Netnews file that you are now reading on your CMS E-Disk by moving
the cursor to the command line and issuing: SAVE ZBACKUP MEMO E  from where
you can then edit and download.  The binary file ZBACKUP.ZIP containing
these three files (4100 bytes long) also resides on the PSUVM Kermit
Product Disk (which can be accessed by issuing the command: PRODUCT KERMIT
downloaded and unzipped from there).

-----------------------------ZBACKUP.BAT follows-------------------------
@Echo Off
REM ***********************************************************************
REM  ROUTINE:   ZBACKUP.BAT
REM  PURPOSE:   PKZIP Backup all files specified in file C:\ZBACKUP.INX to
REM             C:\ZBACKUP.ZIP, then to 1.44M diskette using DOS BACKUP.
REM  PACKAGE:   Backup of Personal PC files
REM  CALLS:     PKZIP and DOS BACKUP command.
REM  FILES NEEDED: ZBACKUP.INX, ZBACKUP.HLP
REM  CALLED BY: ZBACKUP    or   ZBACKUP ?  to display Help.
REM  MODIFY:    A:, the floppy drive, may be changed to any desired drive.
REM  AUTHOR:    H. D. Knoble, HDK@PSUVM, 02/13/92
REM ************************************************************************
if "%1" == "?" GoTo Help
if "%1" == "" GoTo Next
Echo .
Echo $$Error: Invalid Syntax: %0 %1 %2 %3 %4 %5 %6 %7 %8 %9
Echo .
GoTo Done
:Next
if exist C:\ZBACKUP.INX GoTo BackThem
Echo .
Echo $$Error: C:\ZBACKUP.INX not found.
Echo .
GoTo Done

:BackThem
REM a(add), P(include pathnames), J(don't mask hidden/system/ronly files)
REM w(include hidden/system/ronly files), z(ask for zip comment).
DIR C:\ > C:\C-Disk.DIR
PKZIP -a -P -J -w -z C:\ZBACKUP.ZIP C:\C-Disk.DIR @C:\ZBACKUP.INX
if errorlevel 1 GoTo WrapUp
if not exist C:\ZBACKUP.ZIP Goto WrapUp
Echo .
Echo ZBACKUP: To bypass DOS BACKUP press Ctrl-Break at its prompt.
Echo          DOS BACKUP beginning now...
BACKUP C:\ZBACKUP.ZIP A:
if errorlevel 1 GoTo Done
Echo .
Echo You may now ERASE C:\ZBACKUP.ZIP after verifying C:\ZBACKUP.ZIP is backed
up.
Echo To verify this: issue DIR A:BACKUP.* for each diskette BACKUP called for;
Echo Sum these sizes; the sum should equal the size of the file C:\ZBACKUP.ZIP.
Echo .
Echo *** ZBACKUP is Finished ***
GoTo Done

:Help
if not exist c:\zbackup.hlp Goto NoHlp
type c:\zbackup.hlp | more
GoTo Done
:NoHlp
Echo Please copy the file ZBACKUP.HLP to C:\ZBACKUP.HLP and reissue ZBACKUP ?
Echo or edit this file with your favorite editor to display it.
GoTo Done
:WrapUp
REM In case called from a Shell or Windows, pause to read error messages.
pause

:Done
if exist c:\C-Disk.DIR erase c:\C-Disk.DIR
REM End ZBACKUP.BAT

--------------------------ZBACKUP.HLP follows---------------------------
                            ZBACKUP.BAT
                      H. D. Knoble - 2/13/92

                      ZBACKUP - Zip Backup Utility

PURPOSE: To backup all filespecs specified in the index file, C:\ZBACKUP.INX, in
         PKZIP (by Phil Katz) format to diskette(s) in drive A:

SYNTAX: ZBACKUP                or        ZBACKUP ?

REQUIREMENTS: There is enough disk space in the root directory of C: to hold
              the file ZBACKUP.ZIP. Index file C:\ZBACKUP.INX must be present.

RESULTS: The file C:\ZBACKUP.ZIP will be created such that all files specified
         in the file C:\ZBACKUP.INX will be compressed to C:\ZBACKUP.ZIP. The
         The Backup file will include pathnames.

DETAILED USE: BACKUP, VIEWING CONTENTS, AND RESTORE

The file A:\ZBACKUP.INX is a sample ASCII index file; the index file can contain
any valid DOS filespec including wildcards; it may contain filespecs from any
valid mixture of PC drives.

 TO DISPLAY THIS DOCUMENTATION Issue: ZBACKUP ?

 TO DO AN ACTUAL BACKUP OF SELECTED FILES Issue:
  1) EDIT C:\ZBACKUP.INX        and make sure this inclusive list suits you.
  2) ZBACKUP                    to do actual backup

 TO RESTORE Issue:
  0) RESTORE B: C: /D   this should display the BACKUP contents as the single
                        file ZBACKUP.ZIP
  1) RESTORE B: C:      this puts B:\BACKUP.001, .002, ...back to C:\ZBACKUP.ZIP
  2) MD C:\TEMP
     CD C:\TEMP         create a subdirectory to hold restored files.
     PKUNZIP -d -j C:\ZBACKUP.ZIP filespec
     e.g., PKUNZIP -d -j C:\ZBACKUP.ZIP WATFOR77\*.FOR
           will restore what might have been C:\WATFOR77\*.FOR to
           C:\TEMP\WATFOR77\*.FOR in a safe way, prompting to replace any
           filespecs already there.

   NOTE: If only one diskette is needed to hold your C:\ZBACKUP.ZIP file, then
         the file A:\BACKUP.001 is in fact a Zip file and may be treated as
         such. I.e., DOS 5.0 Backup doesn't alter C:\ZBACKUP.ZIP; so if it fits
         on one diskette it remains a Zip file under the fileid, BACKUP.001.
         Thus in this case Steps 0 and 1 above could be eliminated and at Step
         2 issue instead: PKUNZIP -d -j A:\BACKUP.001 filespec.

 TO MAKE A DIRECTORY, ASCII TEXT FILE BACKUP.DIR, OF ALL BACKED UP FILES Issue:
  1) RESTORE B: C:
  2) PKUNZIP -V C:\ZBACKUP.ZIP > C:\BACKUP.DIR


 TO ADD/UPDATE files to ZBACKUP.ZIP add them to C:\ZBACKUP.INX and (re)issue:
  the command: ZBACKUP

 TO GET BRIEF HELP FOR PKZIP ROUTINES Issue:
   a) PKUNZIP or PKUNZIP -h
   b) PKZIP   or PKZIP -h


MOTIVATION, DETAILED DESCRIPTION, AND BACKGROUND

ZBACKUP is a simple aid to help you fulfill your responsibility to yourself by
backing up not all DOS files, but rather ones that you have what you feel is
significant investment in and which couldn't be re-installed in the event of a
fixed disk disaster. In general it is recommended that you make at least one
formal full DOS Backup of your entire fixed disk, probably using the DOS Backup
command. Whether or not you do this, ZBACKUP is a utility that you may wish to
run either weekly or daily, depending on how much you use your PC.

The disadvantage of ZBACKUP is that YOU must keep the index ZBACKUP.INX up to
date and YOU must know WHICH files in a package (e.g., like DBASE III, EXCEL,
WordPerfect, etc.) that are not "re-installable". The advantage is that in many
cases all such files that you have significant time investment in on a typical
100M fixed disk system will Zbackup in 2 or 3 minutes to one or two (1.44M)
diskettes. You may wish to rotate two or three sets of Zbackup diskettes both to
insure better integrity and in some cases to retrieve files that were
inadvertently changed and then backed up once (but not to all sets of Zbackup
diskettes).

ZBACKUP.BAT is simple tool that does two actions: (1) uses Phil Katz's PKZIP to
compress a SELECTED index of filespecs in the file C:\ZBACKUP.INX; and (2) then
back up the compressed result to diskette using the DOS BACKUP command. ZBACKUP
calls no other programs other than PKZIP and DOS's BACKUP command. To restore
files requires DOS RESTORE and PKUNZIP. The DOS BACKUP is to drive A: unless you
edit ZBACKUP.BAT and change that. As it turns out, DOS Version 4.0 and above
BACKUP command doesn't change the file C:\ZBACKUP.ZIP (except for splitting it
across diskette if it happens not to fit on the one diskette). Thus you can add
up the sizes of the DOS Backup piece(s) and this will equal the size in bytes of
C:\ZBACKUP.ZIP. Likewise if C:\ZBACKUP.ZIP fits on one diskette (often the
case), after DOS Backup you can issue: PKUNZIP -v A:\BACKUP.001 to view its
contents, just as you'd do for a regular Zip file. If C:\ZBACKUP.ZIP is not
erased between ZBACKUP commands, files there will be "updated" (or added if you
add filespecs to C:\ZBACKUP.INX). One enhancement you may wish to add is to
invoke your favorite editor on the file ZBACKUP.INX just before PKZIP is called
in ZBACKUP.BAT. Another would be to use invoke your favorite editor to display
this Help file; e.g., EDIT C:\ZBACKUP.HLP
                                                                  HDK - 10/6/92.

------------------------Example of ZBACKUP.INX follows-------------------
C:\KEDIT\*.KEX
C:\KEDIT\*.KML
C:\BATCH\*.*
C:\UTIL\*.*
C:\REXX\*.REX
C:\WATFOR77\*.FOR
C:\WATFOR77\*.DAT
C:\CONFIG.SYS
C:\AUTOEXEC.BAT
C:\DOS\*.INI
C:\DOS\*.BAT
C:\ZBACKUP.INX
D:\DATA\*.
Newsgroups: comp.sys.ibm.pc.misc,comp.sys.ibm.pc.hardware