Monitored Robocopy Replication

Replace DFS with a monitored robocopy script.

DFS has been a great system you would use to replicate files from one site to another; however one of the biggest limitations is the inability of monitoring it, IE – daily log to show that:

  • It is still working
  • To show WHAT is getting replicated

As a replacement I have taken a step backwards and setup a robocopy script as a scheduled task to mirror a source in a different location and a second script to send you the logs. Plain and simple.

The robocopy script is as follows:


::SET _source=”c:Example Source Folder”
SET _source=
SET _dest=”d:Example Destination Folder”
SET _dest=f:

SET _what=/COPYALL /B /SEC /A-:H /MIR /XD “C:System Volume Information”
:: /COPYALL :: COPY ALL file info

:: /B :: copy files in Backup mode.
:: /SEC :: Copy security Descriptors
:: /MIR :: MIRror a directory tree
:: /XD  :: Copy except for the following folders
:: /XF  :: Exclude file(s) – ie the log file
:: /A   :: Set attributes

SET _options=/R:3 /W:5 /LOG:C:robolog.txt /NP /NDL
:: /R:n :: number of Retries
:: /W:n :: Wait time between retries
:: /LOG :: Output log file; can be placed of a network share
:: /NFL :: No file logging
:: /NDL :: No dir logging
:: /NP  :: No Progress – does not show progress bar

ROBOCOPY %_source% %_dest% %_what% %_options%

Now that we have replication, lets get some logging:

Set objMessage = CreateObject(“CDO.Message”)
objMessage.Subject = “Replication logs”
objMessage.From = “”
objMessage.To = “”
objMessage.TextBody = “Please find attached you backup logs.”
objMessage.AddAttachment “c:robolog.txt”
objMessage.Configuration.Fields.Item _
(““) = 2
objMessage.Configuration.Fields.Item _
(““) = “servername
objMessage.Configuration.Fields.Item _
(““) = 25