In my server I have 4 hard drives and each has a purpose:
- Operating system – WinXP
- Personal files such as family pictures, home movies & mp3s
- Backup of personal files
- Media drive containing ripped DVDs
I used to setup hard drives 2 & 3 in a RAID 1 which is a mirrored raid array. That way both hard drives contain the exact same data so if one ever failed I would not loose the data. Since then I’ve found that sometimes I erase data that I don’t mean to and sometimes it’s hard to get it back. So I came up with a solution. I use a batch file to backup my data nightly to from hard 2 to hard drive 3. That way if I delete some data it actually doesn’t get deleted off my backup drive. If I overwrite something I didn’t mean to I have until the nightly backup to retreive it. The dos utility xcopy works great for that. Here is a link to an xcopy users guide http://www.seqsoft.com/xcopy_ug.pdf
In the batch file I start off by saving the date and the start time to two variables:
SET DATE=%date:~4,2%-%date:~7,2%-%date:~10,4%
SET START=%time:~0,2%%time:~3,2%%time:~6,2%
I then use xcopy with a bunch of switches to copy any new data to the backup hard drive. I also create a log file called InProcess.log so I can go back later and check that everything is working alright.
xcopy /d /c /e /r /y /f e:\ f:\ >f:\backuplog\InProcess.log
Here is a list of the switches I use:
- /d - Copies files changed on or after the specified date. If no date is given, copies only those files whose source time is newer that the destination time.
- /c - Continues copying even if errors occur.
- /e - Copies directories and sub-directories, including empty ones.
- /r - Overwrites read-only files.
- /y - Suppresses prompting to confirm you want to overwrite an existing destination file.
- /f - Displays full source and destination file names while copying.
I then specify the source drive e:\ which is my personal files drive.
Next the destination drive f:\ which is my backup hard drive is specified.
Then I tell it to white to a log file instead of to the screen using >f:\backuplog\InProcess.log
After the xcopy command I save the end time to a variable:
SET END=%time:~0,2%%time:~3,2%%time:~6,2%
I then rename the InProcess.log file that was created to a date and time stamp that says what time the process was started and what time it ended.
rename f:\backuplog\inprocess.log “%DATE% %START%-%END%.log”
So I save all of these lines into a batch file called backup.bat. Here is what the entire batch file looks like:
SET DATE=%date:~4,2%-%date:~7,2%-%date:~10,4%
SET START=%time:~0,2%%time:~3,2%%time:~6,2%
xcopy /d /c /e /r /y /f e:\ f:\ >f:\backuplog\InProcess.log
SET END=%time:~0,2%%time:~3,2%%time:~6,2%
rename f:\backuplog\inprocess.log “%DATE% %START%-%END%.log”
The batch file is great but I need a way to automate it so I don’t have to remember to run the batch file whenever I want to backup my data. It’s also nice to schedule the backup in the middle of the night when I most likely won’t be using my computer to access the server. I use a neat little windows utility called Task Scheduler.
How To Schedule Tasks in Windows XP
While scheduling tasks you basically just browse for the batch file then set when you want the task to run and how often.
There are other solutions for backing up data but I like batch files, it’s free, easy and I don’t have to use some third party program.