|
Automate Files Backup with DOS Batch Script 2007-06
We have suggested using Windows XP's build-in backup tool to backup your files. In the past few months, we have received more dissatisfied comments than favorable notes. Mostly, readers complained about the complexity of setting up the backup jobs and the file restoring process. Most desired a simple, automated file copying process.
Windows XP can run scripts. Searching through the internet, we were able to assemble this simple file copying script. It creates a folder based on Year, Month, Day when it run. After the folder is created, it copies files and folders from a location of your choice, to the YYYYMMDD folder. Combining it with the build in scheduler, you will have a simple and reliable scheduled backup procedure.
The batch file shown below, changes directory to f:\backup\, where F is our USB Hard Drive. Then, it uses the computer's date time function to figure out yyyymmdd and create the yyyymmdd folder. The next step does the copy, from My Documents to the f:\backup\yyyymmdd folder.
You will need to follow these instructions to make the batch file work on your computer. The file you downloaded is named backup.txt. Open it with Notepad to edit it.
First, change the f:\backup\ to wherever you want to backup your files to. Our USB drive is drive F, and we have crated a backup folder to keep all our yyyymmdd folder/files in it.
REM NOTE 1: change directory where you want the backup file to be and created f:\backup\
Second, modify the copy command line. This line has three pieces to it.
REM NOTE 3: copy the files you want to the newly created YYYYMMDD folder.
- XCOPY, is the command to copy the files.
- The "C:\Documents and Settings\Eric\My Documents" is where all the files you want to copy from.
- f:\backup\%date:~-4,4%%date:~-10,2%%date:~-7,2% /S is where the destination folder is.
After you made all the changes, save the backup.txt. Then, save it again as backup.bat. To test the script, double click on backup.bat, and it should create a folder on f:\backup\yyyymmdd, then all your files in C:\Documents and Settings\Andy\My Documents will be copied over.
You can run this process yourself when you remember to backup your files, or the alternative is to use the build in task scheduler.
|