This utility from Microsoft enables you to back up many folders from one drive to another in an intelligent way. It does not waste time copying files that have not changed. It copies only the files with a newer date and time over the older ones.
You can put the command in a BAT file to make it easier. For example, if "MyDocs" is the folder you want to back up from the C: drive to the D: drive, type::
C:> C: C:> cd MyDocs C:> RoboCopy C:\MyDocs D:\MyDocs /mir |
The "/mir" means to mirror the folders, so that they are the same as the C: version. There are many other "/ options" you can read at the Microsoft page (or see below).
You can also use this with the AT command to AuTomatically backup AT a certain time,
such as 2:00 am. From DOS, type
at 02:00:00 /every:m,t,w,th,f,s,su RoboCopy C:\MyDocs D:\MyDocs /mir
You can verify the command by typing AT
Note that the source and destination do not have to be identical, but usually you would want them to be. In the following example, all the c:\imail files will copy to the d:\mydocs folder.
Status ID Day Time Command Line
---------------------------------------------------------------
1 Each M T W Th F S Su 2:00 AM robocopy c:\imail d:\mydocs /mir
To delete this scheduled task, type
at 1 /delete
------------------------------------------------------------------------------- ROBOCOPY v 1.71 : Robust File Copy for Windows NT : by kevina@microsoft.com ------------------------------------------------------------------------------- Started : Fri Oct 19 15:58:31 2001 Usage : ROBOCOPY source destination [file [file]...] [options] source : Source Directory (drive:\path or \\server\share\path). options : /S : copy Subdirectories, but not empty ones. /T : Timestamp all destination files, including skipped files. /R:n : number of Retries on failed copies - default is 1 million. /TBD : wait for sharenames To Be Defined (retry error 67). /X : report all eXtra files, not just those selected. /A+:[R][A][S][H] : add the given Attributes to copied files. /XA:[R][A][S][H] : eXclude files with any of the given Attributes /XF file [file]... : eXclude Files matching given names/paths/wildcards. /XC | /XN | /XO : eXclude Changed | Newer | Older files. /Z : Copies files in restartable mode. |
The AT command schedules commands and programs
to run on a computer at a specified time and date. The Schedule service must be running to use the AT command. AT [\\computername] [ [id] [/DELETE] | /DELETE [/YES]] AT [\\computername] time [/INTERACTIVE] [ /EVERY:date[,...] | /NEXT:date[,...]] "command" \\computername Specifies a remote computer. Commands are scheduled on the local computer if this parameter is omitted. id Is an identification number assigned to a scheduled command. /delete Cancels a scheduled command. If id is omitted, all the scheduled commands on the computer are canceled. /yes Used with cancel all jobs command when no further confirmation is desired. time Specifies the time when command is to run. /interactive Allows the job to interact with the desktop of the user who is logged on at the time the job runs. /every:date[,...] Runs the command on each specified day(s) of the week or month. If date is omitted, the current day of the month is assumed. /next:date[,...] Runs the specified command on the next occurrence of the day (for example, next Thursday). If date is omitted, the current day of the month is assumed. "command" Is the Windows NT command, or batch program to be run. If it is not a .EXE you must precede it with cmd /c |
It is suggested that you use the AT command with a Batch file, so you can test the Batch file separately before putting it on automatic execution.
This backs up all the Web Site Log Files from the C: drive to the D: drive using Microsoft's RoboCopy command. It keeps a record of its activity in RoboCopy.Txt
rem Copy Log Files from C: to D:\_LogFiles C: cd \WINNT\System32\LogFiles rem make a backup for analysis copy RoboCopy.Txt RoboCopy.Bak RoboCopy C:\WINNT\System32\LogFiles D:\_LogFiles /s /log:C:\RoboCopy.Txt :END NotePad C:\RoboCopy.Txt |
This backup up all the Web sites from the D: drive to the T: drive on another server. It first checks to see if the T: is mapped.
rem This backs up all the Web sites from D: to T: on another server if not exist T:\HTTP\NETSTAT.BAT goto END D: cd \HTTP rem make a backup for analysis copy D:\RoboCopy.Txt D:\RoboCopy.Bak RoboCopy D:\HTTP T:\HTTP /s /mir /log:D:\RoboCopy.Txt :END NotePad D:\RoboCopy.Txt |
The above BAT files would be activated with the following AT commands.
Status ID Day Time Command Line ------------------------------------------------------------------------------- 1 Each M T W Th F S Su 2:00 AM cmd/c D:\HTTP\COPY_D_T.Bat 2 Each M T W Th F S Su 1:00 AM cmd/c C:\WINNT\System32\LogFiles\LogF_C_D.bat |
Here the AT command has launched the COPY_D_T.BAT file. It does not display what it is doing because all the activity is being saved in the D:\RoboCopy.Txt file for later viewing.
https://superuser.com/questions/951942/getting-date-in-a-batch-file
You can reformat the representation of the date that is stored in the %date%
environment
variable
set YyyyMmDd=%DATE:~6,4%%DATE:~3,2%%DATE:~0,2% C: cd \Tools XCOPY G:\Data\TM5\Common\*.* G:\Data\TM5\Common%YyyyMmDd% <D /d /y XCOPY G:\Data\TM5\Data\Inter\*.* G:\Data\TM5\Data\Inter%YyyyMmDd% <D /d /y
XCOPY G:\Data\TM5\Common\*.* C:\Data\TM5\Common%YyyyMmDd%
<D /d /y C:\Tools\ZIP -u G:\DATA\TM5\Common.zip
G:\Data\TM5\Common\*.* |
rem Daily
backup of TeleMagic with XCOPY and ZIP to files with daily date names set YyyyMmDd=%DATE:~6,4%%DATE:~3,2%%DATE:~0,2% C: cd \Tools rem XCOPY G:\Data\TM5\Common\*.* G:\Data\TM5\Common%YyyyMmDd% <D /d /y rem XCOPY G:\Data\TM5\Data\Inter\*.* G:\Data\TM5\Data\Inter%YyyyMmDd% <D /d /y rem XCOPY G:\Data\TM5\Common\*.* C:\Data\TM5\Common%YyyyMmDd% <D /d /y rem XCOPY G:\Data\TM5\Data\Inter\*.* C:\Data\TM5\Data\Inter%YyyyMmDd% <D /d /y XCOPY G:\Data\TM5\Common\*.* C:\Data\TM5\Common <D /d /y XCOPY G:\Data\TM5\Data\Inter\*.* C:\Data\TM5\Data\Inter <D /d /y C:\Tools\ZIP -urp G:\DATA\TM5\Common%YyyyMmDd%.zip G:\Data\TM5\Common\*.* C:\Tools\ZIP -urp G:\DATA\TM5\Data\Inter%YyyyMmDd%.zip G:\Data\TM5\Data\Inter\*.* XCOPY G:\DATA\TM5\Common%YyyyMmDd%.zip C:\DATA\TM5\Common.zip <F /d /y XCOPY G:\DATA\TM5\Data\Inter%YyyyMmDd%.zip C:\DATA\TM5\Data\Inter.zip <F /d /y pause rem <D and <F are to pass Directory or File to the XCOPY |
at /delete at 01:00:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 01:10:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 01:20:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 01:30:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 01:40:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 01:50:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 02:00:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 02:10:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 02:20:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 02:30:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 02:40:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 02:50:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 03:00:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 03:10:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 03:20:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 03:30:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 03:40:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 03:50:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 04:00:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 04:10:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 04:20:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 04:30:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 04:40:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 04:50:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 05:00:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 05:10:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 05:20:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 05:30:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 05:40:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 05:50:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 06:00:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 06:10:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 06:20:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 06:30:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 06:40:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 06:50:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 07:00:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 07:10:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 07:20:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 07:30:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 07:40:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 07:50:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 08:00:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 08:10:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 08:20:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 08:30:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 08:40:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 08:50:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 09:00:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 09:10:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 09:20:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 09:30:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 09:40:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 09:50:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 10:00:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 10:10:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 10:20:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 10:30:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 10:40:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 10:50:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 11:00:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 11:10:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 11:20:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 11:30:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 11:40:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 11:50:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 12:00:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 12:10:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 12:20:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 12:30:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 12:40:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 12:50:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 13:00:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 13:10:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 13:20:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 13:30:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 13:40:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 13:50:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 14:00:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 14:10:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 14:20:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 14:30:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 14:40:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 14:50:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 15:00:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 15:10:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 15:20:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 15:30:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 15:40:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 15:50:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 16:00:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 16:10:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 16:20:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 16:30:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 16:40:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 16:50:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 17:00:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 17:10:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 17:20:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 17:30:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 17:40:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 17:50:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 18:00:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 18:10:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 18:20:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 18:30:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 18:40:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 18:50:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 19:00:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 19:10:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 19:20:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 19:30:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 19:40:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 19:50:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 20:00:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 20:10:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 20:20:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 20:30:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 20:40:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 20:50:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 21:00:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 21:10:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 21:20:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 21:30:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 21:40:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 21:50:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 22:00:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 22:10:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 22:20:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 22:30:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 22:40:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 22:50:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 23:00:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 23:10:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 23:20:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 23:30:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 23:40:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 23:50:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT at 00:00:00 /every:m,t,w,th,f,s,su cmd /c W:\Copy_W_D.BAT |