home *** CD-ROM | disk | FTP | other *** search
/ Windows News 1997 January / WnewsNo40.iso / bench / DOSLFN16 / DOSLFNBK.TXT < prev    next >
Text File  |  1996-09-01  |  26KB  |  544 lines

  1. DOSLFNBK v 1.6 - Backs up/restores Win95 long filenames in DOS
  2.  
  3. Copyright (c) 1995,1996 D.J. Murdoch.
  4.  
  5. 0. Contents of this file
  6.  
  7.    1. Syntax
  8.    2. Description
  9.    3. Details
  10.    4. Memory Limitations
  11.    5. Safety
  12.    6. Recovery from Total Disk Failure
  13.    7. License
  14.    8. Release History
  15.    9. Acknowledgments
  16.  
  17. 1. Syntax:
  18.  
  19.       DOSLFNBK drive:directory [options]
  20.  
  21.         will back up all the long filename records in the named
  22.         directory and subdirectories of it to a file called
  23.         BACKUP.LFN.
  24.  
  25.       Options:
  26.         /f filename  Back up to this file instead (default .LFN
  27.                      extension)
  28.         /force       Force DOSLFNBK to go ahead without asking questions,
  29.                      even when it may be unsafe
  30.         /l           List contents of backup file
  31.         /nr          No recursive:  don't do subdirectories
  32.         /nt          Don't restore times from LFN backup
  33.         /p           Prompt before each filename restore (ignored
  34.                      during saves)
  35.         /r           Restore from existing backup
  36.         /s directory Skip directory
  37.         /v           Give running status report
  38.         /d filename  Write a detailed debugging log to filename
  39.  
  40.       Examples:
  41.  
  42.         For recovery from a total disk failure, see section 6 below.
  43.  
  44.         To back up every long filename on the disk into BACKUP.LFN:
  45.  
  46.            doslfnbk c:\
  47.  
  48.         To restore just the Windows directory and subdirectories:
  49.  
  50.            doslfnbk c:\windows /r
  51.  
  52.         To restore just the root directory, but no subdirectories:
  53.  
  54.            doslfnbk c:\ /r /nr
  55.  
  56.         To backup everything except the MS Internet Explorer cache and
  57.         history directories:
  58.  
  59.    doslfnbk c:\ /s \progra~1\micros~1\cache /s \progra~1\micros~1\history
  60.  
  61.         To backup the current directory and subdirectories:
  62.  
  63.            doslfnbk .
  64.  
  65.         To restore the "Program Files" directory name and its
  66.         subdirectories, you need two runs:
  67.  
  68.            doslfnbk c:\PROGRA~1 /r
  69.            doslfnbk c:\ /r /p /nr
  70.  
  71.         On the second run, you'll be prompted for each name to restore;
  72.         just say yes when you see "Program Files".
  73.  
  74.         To see what filenames in the "Program Files" directory and its
  75.         subdirectories are in the current BACKUP.LFN file:
  76.  
  77.            doslfnbk c:\PROGRA~1 /l
  78.  
  79. 2. Description:
  80.  
  81.         Microsoft's Windows 95 introduces long filenames (LFNs), and
  82.         they are mostly compatible with old software.  However, there
  83.         are some problems.  Old backup programs don't recognize LFNs, so
  84.         they don't get properly backed up.  Worse, the Win95 backup
  85.         program doesn't support a lot of common backup hardware (e.g.
  86.         Colorado Memory Systems tape drives using accelerator cards) and
  87.         won't run in DOS mode, so recovery from a catastrophic disk
  88.         failure can be really difficult.
  89.  
  90.         To address this problem, Microsoft put a program called LFNBK on
  91.         the Win95 CD ROM to back up your LFNs.  However, it's very
  92.         inconvenient to use.  It requires changes to your Control Panel
  93.         settings before and after use, and it works by stripping all the
  94.         LFNs off your disk --- so you need to restore them again after
  95.         you've done your backup to tape.  It will only run after Win95
  96.         has booted, so again you've got big problems after a
  97.         catastrophic disk failure.  If you've got a program that is
  98.         completely incompatible with LFNs then you might want to use
  99.         LFNBK, but for routine system backups it's too much of a pain.
  100.  
  101.         I wrote DOSLFNBK to address these problems.  It runs in any
  102.         version of DOS that can see your disk, and can both backup and
  103.         restore your files there.  During backup, it makes no changes to
  104.         the names, so you can routinely run it just before a tape backup
  105.         and not have to undo the damage afterwards.  It also allows
  106.         partial backups and partial restores; I'm pretty sure LFNBK is
  107.         an all-or-nothing affair.
  108.  
  109.         The downside of DOSLFNBK is that it has to work on the disk
  110.         below the file system level.  This means that it needs to lock
  111.         the disk to make sure no other programs are writing to the disk
  112.         while it is running.  This may cause errors in the other
  113.         programs; I recommend shutting them down before running
  114.         DOSLFNBK, or running it in a single-tasking DOS session.
  115.  
  116. 3. Details:
  117.  
  118.         Contents of this section:
  119.           - what DOSLFNBK does
  120.           - how to specify which directory to back up
  121.           - existing long filenames
  122.           - date information
  123.           - changed files
  124.           - file attributes
  125.           - the /v verbose option and the /d debug option
  126.           - running in Windows
  127.           - the /force option to ignore warnings
  128.           - the /s option to skip directories
  129.           - large directories
  130.           - the LOCK and UNLOCK commands
  131.           - DOSLFNBK, disk defragmenters and directory sort utilities
  132.           - DOSLFNBK and XCOPY
  133.           - exit codes
  134.  
  135.         When doing a backup, DOSLFNBK reads the directories on the disk
  136.         and writes copies of all of the LFN records to the binary
  137.         BACKUP.LFN file (or whatever file you specify with /f).  If you
  138.         use the /nr option, it will work only on the specified
  139.         directory; otherwise, it saves those entries as well as
  140.         everything in any subdirectory below it.
  141.  
  142.         Relative directory specifications are supported, and DOSLFNBK
  143.         understands SUBST to some extent.  (I believe it's possible with
  144.         a complicated network of SUBST, JOIN, etc. to confuse it; don't
  145.         do that!)
  146.  
  147.         The directory name itself won't be backed up or restored; only
  148.         the files and subdirectories within it. There is no way to
  149.         specify a subset of the files; you have to use the /p prompting
  150.         option if you want this.
  151.  
  152.         The original drive letter is not stored in BACKUP.LFN, so you
  153.         can use DOSLFNBK to save the long filenames on one drive, use a
  154.         DOS utility to move them to another drive, and then restore the
  155.         filenames there.  You must restore to the same full path as was
  156.         originally backed up; you can't graft a subdirectory branch onto
  157.         a new tree.
  158.  
  159.         DOSLFNBK will normally not overwrite an existing LFN with a
  160.         different one; you should rename the file to its 8.3 alias
  161.         before running if you want to restore an old name, or run with
  162.         the /p option for individual prompting.
  163.  
  164.         Normally, DOSLFNBK will restore the backed up date information,
  165.         since older DOS versions and DOS utilities probably don't save
  166.         this properly.  You can override this behaviour by using the /nt
  167.         switch.
  168.  
  169.         If during a restore, DOSLFNBK detects that the file size has
  170.         changed, you'll be prompted as to whether you want to restore
  171.         the LFN or not.  If you choose to restore it, the date
  172.         information will *not* be restored, as it is probably incorrect.
  173.  
  174.         During a restore, the file attributes of the file on the disk
  175.         will be kept.
  176.  
  177.         To show you the progress of a run, DOSLFNBK prints a dot for
  178.         about every 10 directories examined or (in /v mode) prints the
  179.         directory and file names.  If it stops printing for more than a
  180.         few seconds, something is probably wrong.  Try running again
  181.         with the /d debug log option, and if it stops again, please
  182.         email me (dmurdoch@mast.queensu.ca) a copy of your log, along
  183.         with a description of your system.  I'm very interested in
  184.         making DOSLFNBK as bug-free as possible.
  185.  
  186.         The /force option tells DOSLFNBK to go ahead without stopping
  187.         for several different warnings (e.g. overwriting the backup
  188.         file).  Use it in a batch file only when you're sure you always
  189.         want it to go ahead.
  190.  
  191.         The /s option tells DOSLFNBK to skip the back up or restore of a
  192.         particular directory.  This is meant as a workaround for the
  193.         memory limitations in DOSLFNBK that are described in section 4
  194.         below.  You can use /s as often as necessary to skip multiple
  195.         directories--the only limit is the command line length.  Note
  196.         that the directory name must be specified using the short
  197.         aliases, e.g. "\PROGRA~1" instead of "\Program files".  Relative
  198.         directory paths using "." and ".." are not supported.
  199.  
  200.         Previous versions of DOSLFNBK used the DOS LOCK and UNLOCK
  201.         commands to lock the disk and prevent errors during restores.
  202.         The current version does this internally.  If you have an old
  203.         batch file that runs LOCK, you'll get warning messages:  "Unable
  204.         to lock drive X:".  Just remove LOCK from the batch file and the
  205.         warnings will go away.
  206.  
  207.         There is one bug in Win95 that the internal locking shows up:
  208.         if you try to restore LFNs to a disk that has any open files on
  209.         it while in a DOS window, the window will suddenly switch to
  210.         full screen.  I don't know of any way to prevent this.
  211.  
  212.         You may be tempted to use an older DOS-based disk defragger or
  213.         directory sort utility that doesn't understand long filenames,
  214.         and then use DOSLFNBK to restore the long filenames.  DON'T DO
  215.         THIS! It is extremely likely to cause errors to your directory
  216.         structure which can't be repaired except by hours and hours of
  217.         work.  The problem is that these programs usually leave a few
  218.         files with wrong but apparently correct long filenames.  You'll
  219.         find that 99 percent of your disk is restored, but some small
  220.         number of files are not.  It is extremely difficult and time
  221.         consuming to find and repair these files.  If you want to use
  222.         these DOS-based programs, you should remove all long filenames
  223.         first (e.g. using LFNBK, or by restoring from tape in DOS).  A
  224.         better solution is to use Win95 compatible versions of these
  225.         utilities.  (Win95 comes with a defragger, and there are shareware
  226.         directory sort utilities available, including mine,
  227.         available in ftp://garbo.uwasa.fi/pc/dirutil as lfnsrt??.zip.)
  228.  
  229.         I have received several messages from people who have tried to
  230.         use XCOPY and DOSLFNBK to back up their disk to a network drive
  231.         or elsewhere, and then found on restore that Win95 won't boot
  232.         properly.  I don't know what is going wrong in these situations,
  233.         but as far as I can tell it's either a bug in XCOPY, or people
  234.         aren't using the right combination of options when they run it.
  235.         If someone has the time to figure out exactly what is going
  236.         wrong, I'd appreciate being told.  In the meantime I don't
  237.         recommend using XCOPY for backups.
  238.  
  239.         When a run is successful, DOSLFNBK exits with ERRORLEVEL 0.
  240.         When something goes wrong, it prints an error message and exits
  241.         with a higher errorlevel. The currently defined error levels
  242.         are:
  243.  
  244.         99 - Syntax error
  245.         98 - Disk init error
  246.         97 - Disk read error
  247.         96 - Disk write error
  248.         95 - Disk directory error
  249.         94 - Directory init error
  250.         92 - Disk lock error
  251.         91 - Internal error
  252.         89 - Memory error
  253.         88 - Multitasker error
  254.         87 - Overwrite error
  255.         86 - Debug error
  256.         85 - Backup read error
  257.         84 - Backup write error
  258.         83 - Backup open error
  259.         82 - Backup close error
  260.         81 - Some directories were skipped because of low memory
  261.  
  262. 4. Memory Limitations:
  263.  
  264.         When running, DOSLFNBK keeps copies of several directories in
  265.         memory at once.  It is written as a real mode DOS program and
  266.         keeps all of this data in the low 640K of memory.  This means
  267.         that in a typical DOS session with 500K of memory available,
  268.         DOSLFNBK will run out of memory when about 15,000 directory
  269.         entries are in memory.  On a restore, up to 3 copies of each
  270.         directory entry may be in memory at once, limiting DOSLFNBK to
  271.         disks with fewer than 5000 directory entries in any branch of
  272.         the directory tree.  (The total number of files on the disk
  273.         doesn't matter; what matters is the number of entries in a
  274.         directory, its parent, grandparent etc., back to the root.)
  275.  
  276.         When I wrote DOSLFNBK, I thought disks approaching this limit
  277.         were very unusual. However, it *is* possible to have such a disk,
  278.         and here's how to find out if you do:
  279.  
  280.         Run your backup with the /V verbose option.  At the end, it
  281.         will print a message something like
  282.  
  283.            Used 255K; restore will require about 264K in DOS session.
  284.  
  285.         If the amount of memory estimated for the restore is more than
  286.         you have available (as reported by the DOS MEM command), you
  287.         might have problems.  You might not; the number reported is
  288.         usually an overestimate.
  289.  
  290.         If it ever turns out that you do run out of memory during a
  291.         restore, you can still restore the LFNs by breaking up the
  292.         restore operation into several steps, restoring different parts
  293.         of your subdirectory tree separately.  In the worst case (more
  294.         than 5000 entries in a single subdirectory), you may have to
  295.         temporarily move files out of the directory and restore the LFNs
  296.         a few thousand (!!) at a time.
  297.  
  298.         Since the original release, it has become clear that there are
  299.         some common situations leading to very large directories. The
  300.         Microsoft Plus! package includes one, and WWW browsers often
  301.         create them while maintaining caches or history lists.
  302.         Unfortunately, the current version of DOSLFNBK doesn't handle
  303.         these very well; it just skips these directories and prints a
  304.         warning message and sets an error level on exit.  I have added
  305.         the /s option to allow you to skip particular directories during
  306.         the backup or restore operation.  A better solution that allows
  307.         all directories to be backed up is in the works.
  308.  
  309. 5. Safety:
  310.  
  311.         DOSLFNBK works with your disk at a level below the file system,
  312.         so if things go wrong during an LFN restore, it's conceivable
  313.         that you could lose whole files or directories.  I've tried to
  314.         make it as safe as I can, but you should follow some simple
  315.         precautions:
  316.  
  317.           - Run Scandisk before DOSLFNBK and get it to fix any errors.
  318.           In particular, if you've run other low level software (e.g. a
  319.           defragger or a directory sorter) that may have messed up the
  320.           LFNs, run Scandisk first.  Better still:  don't use that old
  321.           defragger/directory sorter, because Scandisk may not be able
  322.           to repair all the damage it does.
  323.  
  324.           - Don't turn off or reboot your PC in the middle of a DOSLFNBK
  325.           run.  If there's a power failure or (horrors!) a bug in
  326.           DOSLFNBK forces you to reboot, then Scandisk should be able to
  327.           repair much of the damage.  You may lose some filenames, but
  328.           Scandisk should be able to recover the files themselves.
  329.  
  330.           - If you hit Ctrl-Break or Ctrl-C during a DOSLFNBK restore,
  331.           it shouldn't do any damage other than giving you only a
  332.           partial restore of your LFNs --- but this is *not* a
  333.           well-tested feature, and there may be conditions under which
  334.           you'll suffer worse damage.  Again, Scandisk should be able to
  335.           repair most of it.
  336.  
  337.           - DOSLFNBK was written for version 4.00.950 of Windows 95 (the
  338.           August 1995 release).  It hasn't been tested on the earlier
  339.           beta test versions, or any versions later than the January 96
  340.           fix pack (version 4.00.950a). If the VFAT file structure isn't
  341.           what DOSLFNBK is written for, it could do some real damage.
  342.           In particular, it will *not* work on a VFAT32 disk.  A beta
  343.           tester has told me that it refuses to run on the current beta
  344.           version of VFAT32, but the final release of VFAT32 is not out
  345.           yet, so I don't know what will happen with it.
  346.  
  347.           - This is the third release of DOSLFNBK to the public.  There
  348.           may still be special conditions on your system that it doesn't
  349.           handle.  If you can, try it out when you've got a good second
  350.           backup to make sure it works.  If it doesn't, *please* send me
  351.           details, and I'll attempt to fix it.
  352.  
  353. 6. Recovery from total disk failure:
  354.  
  355.         If your boot disk fails, or you decide to repartition it, then
  356.         you may need to do a full restore from a backup tape.
  357.         Unfortunately, the Win95 backup program provides *no way* to do
  358.         this without re-installing Win95 from the original disks or CD
  359.         ROM.  From reports I've heard, the same is true of the
  360.         just-released Win95 version of Colorado Memory System's backup
  361.         program and some other commercial backup programs.
  362.  
  363.         However, if you have a reliable DOS-based backup program,
  364.         DOSLFNBK will let you do a complete restore from a backup.  I've
  365.         only had to do this once, so these instructions aren't
  366.         guaranteed to cover everything for every system, but they worked
  367.         on mine.
  368.  
  369.         ADVANCE PREPARATIONS:
  370.  
  371.         Before your disk fails (i.e. right now! :-), you need to prepare
  372.         the following:
  373.  
  374.           1. A Win95 startup disk.  If you didn't create one when you
  375.           installed Win95, start the Add/Remove Programs option in
  376.           Control Panel, and click the Startup Disk tab. Then click the
  377.           Create Disk button, and follow the instructions on-screen.
  378.  
  379.           2. A copy of your DOS-based backup/restore program on a floppy
  380.           disk.  It may require EMS memory; if so, you should put
  381.           HIMEM.SYS and EMM386.EXE on your startup disk, and load them
  382.           via CONFIG.SYS.
  383.  
  384.           3. If you use Drivespace disk compression, then you should also
  385.           make sure that the MINI.CAB file from the installation disks
  386.           or the CD ROM is in your Windows directory on the hard disk.
  387.  
  388.           4. A full backup of your disk(s).  Just before creating this,
  389.           run DOSLFNBK to save all of your long filenames.  You'll need
  390.           to create one backup file for each disk.  It's fine to leave
  391.           this on the hard disk so that it ends up on the backup; you
  392.           don't need to have it on floppy disk.
  393.  
  394.         WHEN YOUR DISK FAILS:
  395.  
  396.         Depending on the reason for your disk failure, you may be able
  397.         to skip some of the early steps here.  Read them over, and
  398.         figure out where to start.  If you have to, you can start again,
  399.         so the only thing you lose by starting too far down is time.
  400.  
  401.           1. Make any necessary repairs to your hardware.
  402.  
  403.           2. Boot from your Startup disk, and use FDISK to partition
  404.           your disk.  Use "FORMAT c: /s" to reformat the disk and
  405.           transfer the system files to it.
  406.  
  407.           3. (Optional) Transfer your tape backup software to your hard
  408.           disk.
  409.  
  410.           4. If you're not planning to use Drivespace, you can skip down
  411.           to step 8.
  412.  
  413.           5. If you want to compress your drive, you need to restore
  414.           enough of Win95 to run Drivespace.  Don't restore the whole
  415.           disk; you might not have room for it.  For most people,
  416.           restoring the files in the root directory and the files in the
  417.           Windows directory should be enough.  If you have any essential
  418.           drivers in other directories, you'll need to restore them too.
  419.           Finally, you should restore DOSLFNBK and the data file(s)
  420.           containing the backed up long filenames.
  421.  
  422.           IMPORTANT:  You should not overwrite IO.SYS, but you *should*
  423.           overwrite MSDOS.SYS.  It is a hidden read-only file in your
  424.           root directory.  A good way is to erase MSDOS.SYS before
  425.           starting the restore (use ATTRIB from the Startup disk to
  426.           remove the System, Hidden, Read-only attributes), and then
  427.           tell your restore program not to overwrite existing files.
  428.  
  429.           Restore all those files now.
  430.  
  431.           6. Restore the long filenames by running
  432.  
  433.              DOSLFNBK c:\ /R /V /F backupfilename
  434.  
  435.           7. Remove the Startup disk, and reboot your system.  You may
  436.           get some errors about missing drivers (e.g. no sound card
  437.           drivers), but things should basically work.  Run DriveSpace to
  438.           compress your drives the way you want.
  439.  
  440.           8. Reboot your system in DOS mode or from the Startup disk.
  441.  
  442.           9. Restore all rest of the files on all of your disks from the
  443.           backup now.  See the "IMPORTANT" note in step 5 about
  444.           MSDOS.SYS and IO.SYS.
  445.  
  446.           10. Restore all the rest of your long filenames by running
  447.  
  448.              DOSLFNBK c:\ /R /V /F backupfilename
  449.  
  450.           and if you've also got a D: partition,
  451.  
  452.              DOSLFNBK d:\ /R /V /F backupfilename
  453.  
  454.           You may get messages about some long filenames already
  455.           existing from your first restore; don't worry about those.
  456.  
  457.           11. Some restore programs set the archive bit on all restored
  458.           files; you might want to turn it off (since you've still got
  459.           those files backed up) at this point.
  460.  
  461.         Reboot your system, and things should be back as they were when
  462.         you did your backup!
  463.  
  464. 7. License:
  465.  
  466.         DOSLFNBK is *not* public domain software, but you may use it at
  467.         no charge.  You may distribute unmodified copies of the complete
  468.         DOSLFNBK package, provided your total charge is no more than $1.
  469.         The total cost of a compilation (e.g. a CD ROM) including
  470.         DOSLFNBK must be no more than $1 per package in the compilation.
  471.  
  472.         DOSLFNBK was written in Borland Pascal 7.01, using the excellent
  473.         Object Professional library from TurboPower Software.  You can
  474.         obtain the source code (including an object-oriented low-level
  475.         disk access unit and a huge memory support unit, but not OPro)
  476.         by sending a cheque or money order for $50 (in Canadian or US
  477.         dollars, or the UKP equivalent of $50US) to:
  478.  
  479.          Duncan Murdoch
  480.          337 Willingdon Ave.
  481.          Kingston, Ontario, Canada.
  482.          K7L 4J3
  483.  
  484.         Note:  I will be going overseas from August 1996 to June 1997.
  485.         During this time I will still fill orders, but there are almost
  486.         certain to be delays.
  487.  
  488.         You can also order source code from the Public (software) Library
  489.         (PsL) using MC, Visa, AmEx, or Discover card:
  490.          - by calling 800-242-4775 (US only)
  491.          - by calling 713-524-6394
  492.          - by faxing your order to 713-524-6398
  493.          - by sending your order by Compuserve to 71355,470.
  494.          - by sending your order by Internet to 71355.470@compuserve.com
  495.         PsL only accepts payment in US dollars.  Please give PsL your
  496.         name exactly as it appears on the card, and tell them your
  497.         card's expiry date.  DOSLFNBK is PsL product #14247.
  498.  
  499.         The PsL numbers are for ordering only.  I *cannot* be reached at
  500.         the PsL numbers.  To contact me for information about dealer
  501.         pricing, volume discounts, site licensing, the status of
  502.         shipment of the product, the latest version number or for
  503.         technical information write to me at the address above or at
  504.         the email address below.  I'd especially like to hear bug
  505.         reports and suggestions for improvements.
  506.  
  507.          Internet:   dmurdoch@mast.queensu.ca
  508.  
  509. 8. Release history:
  510.  
  511.        0.0 - first beta test version
  512.        0.1 - kept file attributes of existing file during restore.
  513.        0.2 - made messages more informative; fixed bug in handling
  514.              erased file entries; added check of overwrite of backup
  515.              file; changed default name of backup file to BACKUP.LFN and
  516.              made LFN the default backup extension; added /P option.
  517.        0.3 - fixed memory leak that caused run-time error 203 on large
  518.              restore
  519.        0.4 - added check for successful write of backup file, added
  520.              /force option.
  521.        0.5 - added report of memory use, /d option, many debugging messages
  522.        0.6 - cleaned up messages and debug log, removed disk size
  523.              restriction, added progress dots for non-verbose runs.
  524.        1.0 - first public release --- same as 0.6
  525.        1.1 - unauthorized release
  526.        1.2 - documentation changes and addition of /s option
  527.        1.3 - improved memory management, stopped use of obsolete DOS
  528.              service 1C, speeded up directory expansion on restore
  529.        1.4 - added /L option, support for relative path on command line,
  530.              internal drive locking, support for SUBST etc.  Changed
  531.              exit codes to be compatible with LFNSORT.
  532.        1.5 - public release, same as 1.4c
  533.        1.6 - fixed bug in handling volume labels
  534.  
  535. 9. Acknowledgments
  536.  
  537.         DOSLFNBK was written based on the information in Robert Hummel's
  538.         article on Win95 long filenames in the June/July 1995 issue of
  539.         PC Techniques Magazine.  Thanks are due to the beta testers, who
  540.         suggested many improvements, and several of whom were put to
  541.         considerable inconvenience by early versions that messed up
  542.         their disks.  M. Guffey made a lot of useful suggestions for
  543.         improvements to the documentation.
  544.