Using Robocopy to Mirror Folders

The following batch file can take a source folder and make an exact copy of that folder to another location. This can be useful if you want to have an automated backup run at a specific time by setting up a scheduled task to call this file.

Robocopy will ensure that all NTFS attributes (security rights, etc) will be copied and can restart a copy if the network connection is disrupted.

It can be downloaded from Microsoft in the Windows Server 2003 Resource Kit.

Be aware that if you delete a file in the source folder, this process will also delete it in the mirrored folder when it runs.

————————————-

REM
REM Uses ROBOCOPY, which is from the Windows 2003 Server Resource Kit
REM Flags are:
REM /MIR – Mirrors filesystem including creating directories or deleting files no longer in source.
REM /LOG+: – Appends a LOG file listing the files mirrored or deleted.
REM
REM
“C:\Program Files\Windows Resource Kits\Tools\robocopy.exe” “\\machinename\sourcefolder” “\\machinename\mirrorfolder” /MIR /LOG+:”C:\copylogs\copy.log.txt”

Leave a Reply

Your email address will not be published. Required fields are marked *