Norton Ghost: Automated Batch Files
The following info comes from Dick
Shogren. Personally, I have never made or used an automated batch
file. But many readers have inquired about the best way to configure
one. Read this ENTIRE section before creating a batch file. Here goes:
Hi Rad. I
run a shop where I work on almost all types of PCs except Macs. I see lots
of customers who destroy their systems. It's usually faster to simply
backup their critical data files and re-install Windows.
WinME offered
hope with System Restore, but I found it to be unreliable.
I'm still doing very little with XP, so I don't know if it's any better.
I needed a simple way for customers to back up their C-drive. Ghost
is hardly user friendly. What follows is a batch file that does exactly
this.
It is accessed via either a desktop icon or an item within the
ghost menu. I typically add it as a menu item called "Easy Backup".
It will run directly within windows without booting to a floppy.
Note that this routine assumes you have either a 2nd partition or a
second drive and that it is setup as the D-drive or D-partition. You
can easily modify the file to your own liking if you use other drive
letter assignments. The resultant image file is created using high compression.
One advantage of this (batch) file is that it allows you to keep a total
of (5) image files. This can also be modified as desired if hard drive
space is a problem. This file is used with Ghost v6. I have not tested
it with any other versions. As you may have discovered, you can't always
restore an image created with a different version. There may be some
glitches if the image is spanned (larger than 2 GB).
If anyone has suggestions or comments, feel free to let
me know. Here's the routine for the batch file:
=============
rem - Ghost Backup Routine from c-partition to d-partition
rem - With image date rotation (from oldest to newest).
if exist d:\save5.gho goto full
if exist d:\save4.gho ren d:\save4.gho save5.gho
if exist d:\save3.gho ren d:\save3.gho save4.gho
if exist d:\save2.gho ren d:\save2.gho save3.gho
if exist d:\save1.gho ren d:\save1.gho save2.gho
:full
@echo "You have 5 Ghost backup files on your hard drive"
@echo "Would you like to remove the oldest one?"
choice
if errorlevel 1 goto del1
:del1
del d:\save1.gho
if exist d:\save5.gho ren d:\save5.gho save1.gho
if exist d:\save4.gho ren d:\save4.gho save5.gho
if exist d:\save3.gho ren d:\save3.gho save4.gho
if exist d:\save2.gho ren d:\save2.gho save3.gho
if exist d:\save1.gho ren d:\save1.gho save2.gho
C:\progra~1\norton~1.0\ghost.exe -clone,mode=pdump,src=1:1,dst=d:\Save1
-z2
=========
If one didn't want to be prompted prior to the final operation, I think
you could add "-sure" to the final line.
Thanks, Dick
Update 06.Feb.2003 - Ron Kuper writes to say: Rad, Dick's
batch file has a small flaw that will cause the program to proceed, even if the user presses 'N'
(for 'No'). The flaw:
# choice
# if errorlevel 1 goto del1
# :del1
When making a 'Choice' statement in Dos, the errorlevel check must
go 'Backwards' - from top to bottom, since 'Choice' will issue all the
errorlevels from 1 to the choice made.
In this example we have 2 choices: Y or N.
If user presses 'Y' for 'Yes', choice will return with
'errorlevel 1' alone.
However, if the user will press 'N' for 'No' choice will return with errorlevel 1 & 2! So the statement: "if errorlevel
1 goto del1" will be 'True' in both cases. A correct form of the
batch file (and all other batch files for that matter) will be - "if errorlevel 2 goto end". For our example (The
batch with the correction):
rem - Ghost Backup Routine from c-partition to d-partition
rem - With image date rotation (from oldest to newest).
if exist d:\save5.gho goto full
if exist d:\save4.gho ren d:\save4.gho save5.gho
if exist d:\save3.gho ren d:\save3.gho save4.gho
if exist d:\save2.gho ren d:\save2.gho save3.gho
if exist d:\save1.gho ren d:\save1.gho save2.gho
:full
@echo "You have 5 Ghost backup files on your hard drive"
@echo "Would you like to remove the oldest one?"
choice
if errorlevel 2 goto end
:del1
del d:\save1.gho
if exist d:\save5.gho ren d:\save5.gho save1.gho
if exist d:\save4.gho ren d:\save4.gho save5.gho
if exist d:\save3.gho ren d:\save3.gho save4.gho
if exist d:\save2.gho ren d:\save2.gho save3.gho
if exist d:\save1.gho ren d:\save1.gho save2.gho
C:\progra~1\norton~1.0\ghost.exe -clone,mode=pdump,src=1:1,dst=d:\Save1
-z2
:end
Ron Kuper
Update 28.August.2006 - An interesting thread developed recently in the Rad community forums, which proposes the fully-automated creation of weekly back-up images via a batch file with Ghost 2003 for the owner of an architectural business (located in Mobile) who is responsible for periodically backing-up a bevy of business computers.
The proposed solution is elegant. See here:>
How to setup automated weekly ghost of running operating system (Windows) </update>
Here is *another* batch file from Maurice
Taquino. He writes to say:
I wrote my own batch file to image various partitions. I'm familiar
with DOS batch files, but certainly no expert. So I was glad to have
an example to start with. I especially like the file name rotation scheme.
However, I don't think the one posted earlier works as intended.
I did make the suggested change to the script regarding the errorlevel
and also added an :abort step so I could more easily tell when/where
things were ending. But essentially, my test batch file is the same
as that posted earlier.
Substituting a DOS copy statement for the Ghost batch commands to copy
a text file makes it easier to test the renaming logic. For any noobies
reading this, you can run these tests easily from Windows by opening
one folder view with your test.bat file, and another with a view of
the target folder. You will see the results immediately.
The are 2 main problems with the earlier batch file:
1. there are two renaming blocks, and both are run
every time until after file #5 is created.
2. the most recent archive (#1) is deleted rather
than the oldest (#5).
I realize batch files are like system configurations: highly personal.
For me, I don't care about the oldest archive. If the max is present,
and I need to make room for a new Save1, then the oldest one should
be deleted without asking me, and the batch should continue. My own
version of this batch file is:
@echo off
cls
echo ---------------------------------------------------------
echo Ghost Backup .....hit ctrl-c to abort; otherwise
echo
echo NOTE: GhostPE will PAUSE until you manually press "OK"
echo for each image dump!!
echo ----------------------------------------------------------
pause
cls
:: Ghost Backup Routine from c-partition to d-partition
:: With image date rotation (from oldest to newest).
:: rename files
:: this step "ages" the filenames by increasing each by
1
:: check for max number...#5 is the oldest backup.
:: IF max # of backups reached...delete the file.
:: If max not reached, so what...continue
if exist h:\save_c5.gho del h:\save_c5.gho
if exist h:\save_c4.gho ren h:\save_c4.gho save_c5.gho
if exist h:\save_c3.gho ren h:\save_c3.gho save_c4.gho
if exist h:\save_c2.gho ren h:\save_c2.gho save_c3.gho
if exist h:\save_c1.gho ren h:\save_c1.gho save_c2.gho
if exist h:\venus_5.gho del h:\venus_5.gho
if exist h:\venus_4.gho ren h:\venus_4.gho venus_5.gho
if exist h:\venus_3.gho ren h:\venus_3.gho venus_4.gho
if exist h:\venus_2.gho ren h:\venus_2.gho venus_3.gho
if exist h:\venus_1.gho ren h:\venus_1.gho venus_2.gho
::Image Drive1, Partition1
a:\ghost\ghostpe.exe -clone,mode=pdump,src=1:1,dst=h:\save_c1.gho
-z2 -fx
a:\ghost\ghostpe.exe -chkimg,h:\save_c1.gho -fx
::Image Drive1, Partition2
a:\ghost\ghostpe.exe -clone,mode=pdump,src=1:2,dst=h:\venus_1.gho
-z2 -fx
a:\ghost\ghostpe.exe -chkimg,h:\venus_1.gho -fx
:end
echo Done. Please reboot now.
exit
Here's another note and problem-solving config.sys & autoexec.bat from Mr. J. Houston, from Viet Nam, for those of you who receive the following error message upon restore or checking a Ghost image: Error: "Image file not created with Norton Ghost.
I recently imaged a hard drive following your instructions to split the files into 630-Meg chunks. I couldn't burn the images directly as Ghost is incompatible with my CD burner. So I saved the images to a hard drive and later burned them to to CD-Rs using Nero.
When I did a test restoration, the Ghost program produced an error message that read: "Error: "Image file not created with Norton Ghost" <-- which is a Technical Support document.
This support document advises:
To assign a drive letter:
1. Open Norton Ghost 2003.
2. Click Options.
3. Choose "External storage driver settings."
4. Check "Assign drive letters."
This is impossible running Ghost from DOS. To overcome this impediment, I rewrote a CONFIG.SYS and AUTOEXEC.BAT that installed the usual drivers for a CD-ROM drive and the called GHOST.EXE from the CD-ROM.
This worked perfectly with Ghost detecting a drive letter for the CD drive and properly installing the 5 images stored on 5 CD-ROMs without difficulty.
For completeness:
--> CONFIG.SYS <--
[menu]
menuitem=FROMFLPY, This computer was started from a Ghost boot disk
menuitem=FROMCD, This computer was started from a Ghost bootable CD
[FROMFLPY]
[FROMCD]
[COMMON]
DEVICE = oakcdrom.sys /D:cd1
DEVICE = btdosm.sys
DEVICE = flashpt.sys
DEVICE = btcdrom.sys /D:cd2
DEVICE = aspi2dos.sys
DEVICE = aspi8dos.sys
DEVICE = aspi4dos.sys
DEVICE = aspi8u2.sys
DEVICE = inicd.sys /D:cd3
LASTDRIVE = Z
--> /CONFIG.SYS <--
--> AUTOEXEC.BAT <--
@echo off
SET TZ=GHO+05:00
MOUSE.COM
CLS
LH \MSCDEX.EXE /D:cd1 /D:cd2 /D:cd3
echo Loading...
if %config% == FROMFLPY goto FLPYBOOT
if %config% == FROMCD goto CDBOOT
goto FAILED
:FLPYBOOT
echo Insert Ghost boot disk 2 (containing Ghost.exe)
pause
if exist a:\ghost\ghost.exe goto GHOSTFND
goto FLPYBOOT
:CDBOOT
echo Insert Ghost boot disk 2 (containing Ghost.exe)
echo To run Ghost.exe from a hard disk or CD, press Ctrl-C at the following prompt
echo then change to the appropriate drive letter and type 'Ghost'
pause
if not exist b:\ghost\ghost.exe goto CDBOOT
b:
goto GHOSTFND
:GHOSTFND
cd \ghost
echo Loading...
GHOST.EXE -forceusb -force1394
goto END
:FAILED
echo Unknown boot menu selection
goto END
:END
--> /AUTOEXEC.BAT <--
I made the first CD-ROM bootable and copied these files along with:
oakcdrom.sys
btdosm.sys
flashpt.sys
btcdrom.sys
aspi2dos.sys
aspi8dos.sys
aspi4dos.sys
aspi8u2.sys
inicd.sys
mscdex.exe
COMMAND.COM
mouse.com
mouse.ini
inicd.sys
IBMBIO.COM
IBMDOS.COM
as well as \GHOST\GHOST.EXE
into the root of the CD-ROM and it became a standalone set of back-up CD-ROMs.
There is no rocket science involved but it eliminates that Error: "Image file not created with Norton Ghost" when restoring or checking an image file.
In closing, I want to express my appreciation of the hard work that you have obviously put into your web site and it has proved invaluable to me as I sit in a technologically isolated area.
J Houston
Buon Me Thuot
DakLak Province
Central Highlands
VietNam
See HERE for more batch-file wizardry you might find helpful. These are customized for a particular system, but you might be able to edit them to your particular system. Provided by The C Man. One of the web's best sources for batch-file wizardry is here:> Rob's.
Before closing, I want to take a minute to mention <shameless
plug> a few other Radified guides that you might find helpful. For
example:
|