Backing up Files with DOS Batch Files
d. bodnar 8-26-09
A tried and true method of doing file backups involves using DOS
batch files, the DOS XCOPY command and Windows Scheduler. This method has been used on my primary computer for a number of years. It works well with Windows XP and should work with Vista as well. |
XCOPY The DOS XCOPY command will copy files based on a number of command line arguments. xcopy c:\documents e:\documents /s/e/v will copy the folder "documents" from the C drive to the same directory on the E drive. It will also copy the sub directories under "documents" xcopy c:\documents e:\documents /s/e/v >> edrivelog.txt (note the space before and after ">>") will copy the same files and create a log file of what is copied titled "edrivelog.txt"
|
BATCH files Batch files are DOS scripts that perform a series of steps in the order that they are listed. The batch file below can be created in NOTEPAD and saved with a ".bat" entension time /t > G-log.txt
I would strongly suggest that you run each line of the batch file manually from a DOS prompt before running the batch file automatically. There is a good reason for this. The first time you run each xcopy line you are likely to be asked if the target is a directory or a file - you need to press "D" to indicate directory - if you run the batch file the program will direct all screen output to the log file and you will never see it to respond. The batch will hang up - if this does happen you can click on the DOS window and press D a few times to answer the question "blind" |
Putting it all together I create the batch file (edit it as needed for your use) and save it from NOTEPAD (don't use Word or WordPad as they don't create a clean text file unless you force them to). The file is saved to the root of C but it could go anywhere. Make sure its name has the extension ".bat" Start Windows Scheduler (Start / Programs / Accessories / System Tools / Scheduler) Start a new scheduled task that points to the batch file saved above. Have it run once each day at whatever time is convenient. I check the log files each morning to make sure that things that I worked on the day before were backed up.
|