[<<]Message[>>]    [<<]Author[>>]    [<<]Subject        [<<]Thread[>>]

Number : 4124 Date : 2003-03-24 Author : Garry Deane Subject : Re: I think I have a working set of backup batchfiles. Size(KB) : 3
--- In xxcopy@yahoogroups.com, anders thoresson wrote: > And batch file number two is the one which does the daily work: > > xxcopy "c:\documents and settings\anders\mina dokument\" > /AZ /S > xxcopy /CB "c:\documents and settings\anders\mina dokument\" > "d:\backup\ref\" /AA /S /H /U0 /BX > xxcopy /CB "c:\documents and settings\anders\mina dokument\" > "d:\backup\backup\" /A /S /H /KS /ZY /PZ0 > xxcopy /CB "c:\documents and settings\anders\mina dokument\" > "d:\backup\ref\" /CLONE /PZ0 /TR0 /V0 > > This does seem two work, but since I'm new to xxcopy, > I would like to check with you if I'm missing something > that would be nice to do, or if I even make some big mistake? Here's a couple of thoughts, some just to do with batch style, the others to do with error reporting and making life more convenient. The real part (the xxcopy commands), looks OK but you'll have to test it thoroughly in your own environment to see whether there are any specific changes that are needed. 1. Use variables to define the directories you are going to use. This makes the xxcopy command lines a lot more compact and easier to read and it makes it easier to modify the batch file if you want to change the directory paths at some stage. 2. You need to keep a log of what happened because you probably won't be watching and the display will skip past too quickly to see much anyway. After the computer has shut down, you'd have no idea whether the backup was successful or not. In this case I've used /ON to create a new xxcopy log each time the batch file runs. You could just as easily use /OA to append to the log information each time but the log file will continue to grow endlessly. 3. I suggest you also create an error log if there were any errors. It will be much easier to check this file than to look at the xxcopy log file every morning. If the error log file exists, there was a problem so you can then look at the xxcopy log file to see the details. If it was me, I'd run a startup batch file which checked for the presence of the error log file and if it existed, it would automatically open up the xxcopy log file so you'd know straight away of any problems. 4. I suggest that you also look at using an exclusion specifier file or use /X. Do you have say Word .doc files. If so, you don't really want to copy any .bak files. Similar useless files (for backup purposes) usually exist for other applications. @echo off :: Performs a backup using Xxcopy and a reference directory to :: check for any files which need to be backed up. :: Uses NT/W2k/XP batch commands, needs to be modified for W9x/ME setlocal set src="c:\documents and settings\anders\mina dokument\" set ref="d:\backup\ref\" set dst="d:\backup\backup\" set log="d:\backup\backup.log" set err="d:\backup\error.log" :: Save the previous log files if exist d:\backup\*.log ( if exist d:\backup\*.bak del d:\backup\*.bak ren d:\backup\*.log *.bak ) :: Commence the backup xxcopy %src% /AZ /S :: The /U0 switch can be deleted from the line below but does no harm xxcopy %src% %ref% /CB /AA /S /H /U0 /BX xxcopy %src% %dst% /CB /A /S /H /KS /ZY /PZ0 /ON%log% xxcopy %src% %ref% /CB /CLONE /PZ0 /TR0 /V0 /OA%log% :: Check for any errors and if so, create an error log if %errorlevel% EQU 0 goto :next if %errorlevel% EQU 100 goto :shutdown :: There was an error, create an error log set msg=%date% %time% Error number %errorlevel% occurred during backup echo %msg% >%err% :: Display the error message and wait 20 seconds to allow a ^C abort echo ============================================================ echo %msg% echo Press Ctrl-C to halt the backup and shutdown echo ============================================================ ping -n 21 127.0.0.1 >nul :next :: Carry out zip operation :shutdown :: Issue shutdown command Garry
This message if part of XXCOPY's message Archive. The archive contains all the messages posted at Yahoo!Groups: XXCOPY.