Backup


Backs up one or more files from one disk onto another.

Syntax

backup [source] destination-drive: [/s] [/m] [/a] [/f:size] [/d:date [/t:time] [/I[:[drive:][path]logfile]

Source - Specifies the location of files you want to back up. Source can consist of a drive letter and colon, a directory name, a filename, or a combination.

Destination-drive - Specifies the drive that contains the disk on which you want to store any backup files. The backup files are stored in the BACKUP.nnn and CONTROL.nnn files. That is, backup assigns the names BACKUP.001 and CONTROL.001 to the files it creates on the first backup disk you use, BACKUP.002 and CONTROL.002 to the files it creates on the second backup disk, and so on.

[/s] - Backs up the contents of all subdirectories.

[/m] - Backs up only files that have changed since the last backup, and turns off the archive attribute of the original files.

[/a] - Adds backup files to an existing back up disk without deleting existing files. The /a switch is ignored if the existing backup disk contains backup files that were created by using the backup command from MS-DOS version 3.2 or earlier.)

[/f:size] - Formats the backup disk to the size you specify. (The format command must be present in the current path.) With this switch, you direct backup command formats an unformatted destination disk even if you do not specify the /f switch. When backup finishes formatting, it begins backing up files onto the last disk it formatted. Size specifies the size in kilobytes of the disk to be formatted. If you do not specify size, the /f switch uses the default size of the drive. The following list shows the valid values for size and a brief description of each size:

[/d:date] - Backs up only files modified on or after the specified date. The date format depends on the setting you are using for the country command.

[/t:time] - Backs up only files modified at or after the specified time. Do not use the /t switch without the /d switch

[/I[:[drive:][path]logfile] - Creates a log file and adds an entry to that file to record the backup operation. If you do not specify a location for the log file, backup puts the file in the root directory of the source drive. If you do not specify the logfile, backup names the file BACKUP.LOG. You should not specify a removable drive (such as a floppy disk drive) for this parameter; but once the backup is complete, you can copy the log file to a floppy disk.


Notes

Backing up onto a disk with files
Unless you use the /a switch, backup deletes old files (including read-only files) from a backup disk before adding new files to it.
Backup log file
If you use the /t switch and do not specify a name and location for the log file, the backup command adds a file named BACKUP.LOG to the root directory of the source drive. If the BACKUP.LOG file already exists, backup adds the current entry to the file. A backup log-file entry uses the following format:

· The date and time of the backup appear on the first line.

· Each filename appears on a separate line with the number of the backup disk that contains the file.

The backup log file can assist you later, when you need to identify the files you want to restore. The restore command always returns a file to the original directory or subdirectory recorded in the backup log, creating the subdirectory if necessary.


Labeling backup disks
It is important to label and number backup disks consecutively. As each disk is filled, backup prompts you for the next disk. When you restore files, you need to insert the backup disks into the disk drive in the same sequence of backup disks (MS-DOS version 3.3 or later), use the dir command to check the disk number.
Backup and system files
The backup command cannot back up the system files IO.SYS, MSDOS.SYS, and COMMAND .COM. You can use the sys command to copy these files onto a floppy disk.
Using an old version of the restore command
You cannot use an old version of the restore command (MS-DOS version 3.2 or earlier for files backed up with MS-DOS version 3.3 or later, If you attempt this, MS-DOS displays the following message:
Source does not contain backup file
This error occurs because the format of old backup files differs from the format of files backed up with MS-DOS version 3.3 and later.
Using backup with networks or redirected drives or directories
If you are sharing files on a network, you can back up only those files to which you have access. You should not use backup with a drive that has been redirected with the assign, join, or subst command. If you do, the restore command may not be able to restore the files.
Backup exit codes
The following list shows each exit code and a brief description of its meaning:

0 The backup was successful.

1 No files were found to back up.

2 Some files were not backed up because of file-sharing conflicts.

3 The user pressed CTRL+C to stop the process.

4 The process stopped because of an error.

You can use the error level parameter on the if command line in a batch program to process exit codes returned by the backup command.