Computer and Software Support


DOS Command Backup

External command

Syntax:

BACKUP [d:][path][filename] [d:][/S][/M][/A][/F:(size] [/P][/D:date] [/T:time] [/L:[d:][path]filename]

Purpose: Allows a backup to be made of one or more files.

 

Discussion

When typing in the first path and filename(s), you are instructing the backup command what file is to be backed up. The second path and filename(s) indicates the where you want to store the backup.

DOS rules apply with this command. If you do not specify the first path, backup will assume that the current directory is the one you want backed up.

Wild cards can be used (* and ?) to specify groups.

If errors are encountered during the BACKUP process, the ERRORLEVEL exit code is set as follows:

1. No files could be found to back up.
2. Some files were not backed up due to file conflicts.
3. Terminated when you pressed the Ctrl + Break key combination.
4. Terminated due to any other type of error.

These codes can be used with the batch processing IF command to write backup batch files that test for errors during the backup process.

Files backed up using the BACKUP command are stored in a special, compacted format and are therefore not usable for normal file processing. You must use the RESTORE command to recall them and store them in the normal (un-compacted) format.


 

Options

/A - Does not erase the files on the target disk (DOS normally will erase existing files on the target diskette before it starts backing up the files). Use of this option cancels the prompt to insert a diskette in the target drive before the copying starts, but after the target disk is filled with backed-up files, you will be prompted to insert a new diskette.


 
NOTE:

Dos Version 3.2 and earlier doesn't accept the /A option 


/F:(size) - Formats the target disk (if it is not already formatted). This option uses the FORMAT program which must, therefore, be accessible via the current path. In DOS Versions 4 and 5, you can use F:(size) if the capacity of the target diskette does not match that of the drive in which you put it. For example, if you are using a 360K diskette in a 1.2M drive, (size) can be 160, 180, 320, 360, 720, 1.2, 1.44, or (in DOS Version 5) 2.88.

/L - Makes an entry in the backup log in the file you specify here. If you use this option but do not specify a backup log file, the system creates the file BACKUP.LOG in the root directory of the source drive.

The backup log will contain:

1. The date and time that the files were backed up.
2. The name of the file that was backed up.
3. The number of the backup disk that contains the file.

The information stored in this file can be used when you want to restore a particular file from a backup disk.

If the backup log file you specify already exists, the current entry is added to the existing file.

/M - Only backs up files that have been modified since the last time the BACKUP command was used. This switch checks the archive attribute of a file. If the file's archive attribute is set to off (-A), the file will not be backed up.


 
NOTE:

Do not write protect diskettes because BACKUP alters the attributes as it is backing up the file.

/P - Packs as many files as possible onto each diskette. This option will create a directory when that is the only way to pack more files onto the diskette.

/S - Causes files in the specified directory and all subdirectories below the specified directory to be backed up.

/D:(date) - Backs up files only if they have been created or modified on or after the date you enter.

/T:(time) - Backs up files only if they have been created or modified on or after the time you enter.

 

Example

In the following example, all files in the drive C LETTERS directory that begin with SALE and with any filename extension are backed up onto the disk in drive A.

backup c:\letters\sale*.* a:

BACKUP will display a prompt when it is time to insert the disks. If the /A option is not used, there will also be a warning that any files currently stored on the target disk will be erased.

This page is from http://www.easydos.com. I pasted it on my website to avoid possible broken links. For further help with DOS commands, Check easydos.com out.