Backup--Examples
Suppose you want to back up all the files in the \PUBLIC\SMITH directory on
drive C onto a blank, formatted disk in drive A. To do so, type the following:
backup c:\public\smith\*.* a:
Suppose you need to back up all files in the \PUBLIC\SMITH directory on drive
C onto a 720K floppy disk in drive B. If the floppy disk is unformatted, backup formats it before backing up any files. Because the /s switch is not specified in the following command, files in subdirectories are
not backed up:
backup c:\public\smith\*.* b: /f:720k
To write a simple batch program named SMITH that supports the backup command's exit codes and the /s switch, create a file containing the following commands using any editor.
echo off
rem Smith's backup command
backup c:\public\smith\*.* b: /s
if errorlevel 4 goto error
if errorlevel 3 goto abort
if errorlevel 2 goto conflict
if errorlevel 1 goto no_files
if errorlevel 0 goto success
:error
echo Backup stopped the process due to an error
goto exit
:abort
echo You just pressed CTRL+C to stop the backup
goto exit
:conflict
echo One or more files were not backed up due to a sharing conflict
goto exit
:no_files
echo Sorry, but there were no files to backup
goto exit
:success
echo The backup was successful
goto exit
:exit
For more information about using the if command in batch programs, see the if command.
More Information About Backup
Backup--Notes
Backup