This tutorial will show you how to use a simple Windows Batch file and the task scheduler to create an automated daily backup. We will use the date variable to backup the files into folders with Date as the folder name.
First you will need to open notepad. The easiest way is going to start > run and typing notepad.
copy and paste the following to the notepad and set drive as the destination drive and folder where do you want to backup (here its my D drive and folder name is BCK,and my source folder is C:DVR )and save it with the .bat extension
@echo off
:: variables
set drive=D:\BCK
set folder=%date:~7,2%_%date:~4,2%_%date:~10,4%
set backupcmd=xcopy /s /c /d /e /h /i /r /k /y
echo ### Backing up directory...
%backupcmd% "C:\DVR" "%drive%\%folder%"
echo Backup Complete!
Once you have made the changes that you need, save the file as backup.bat
Steps to schedule this back up.
- Now Open the Control Panel and select Scheduled Tasks
- add a new task by clicking the “Add Scheduled Task” button.
- Click next and then browse. Locate the backup script you just saved and click open
- Select perform this action daily or weekly or monthly as per ur requirement and then click the next button.
- Select enter the time you want the task to run at in the start time box and change the date to the day you would like this task to start running on.
- Click finish.
Now you can test the backup script.
Locate the script in
the scheduled tasks folder, Right click it and select run.
You should see the command window open. When the task is finished,
browse to your backup folder and verify that the files have been copied.
No comments:
Post a Comment