shell Replication using robocopy

@ECHO OFF
:: turn text output off

SETLOCAL
:: variables to be local scope

FOR /f "tokens=1-4 delims=/ " %%a IN ('date /t') DO (SET dDate=%%c-%%b-%%a)
:: sets date variable for naming of files to YYYY-MM-DD format

SET _logfile="C:\%dDate%.log"
:: specify log file name

SET _source="C:\_a\\"
:: source location

SET _destination="C:\_b\\"
:: destination location

SET _what=/COPYALL /B /SEC /MIR
:: /COPYALL :: copy all file info
:: /B :: copy files in backup mode
:: /SEC :: copy files with SECurity
:: /MIR :: MIRror a directory tree

SET _options=/R:0 /W:0 /LOG+:%_logfile% /TS /FP /TEE /BYTES /ETA /NP
:: /R:n :: number of Retries
:: /W:n :: Wait time between retries
:: /LOG :: Output log file (append)
:: /TS :: Include Source file Time Stamps in the output.
:: /FP :: Include Full Pathname of files in the output.
:: /TEE :: Output to console window, as well as the log file.
:: /BYTES :: Print sizes as bytes.
:: /ETA :: Show Estimated Time of Arrival of copied files.
:: /NP :: No Progress (don't show % copied)

ROBOCOPY %_source% %_destination% %_what% %_options%
:: run command with parameters
Uses robocopy to replicate one folder to another. See ss64 and Technet for more information.

Remove /MIR, add /XO and /E for GoLive adaption (copies files over, does not purge or overwrite newer ones).

If using Windows 7, Techrepublic have a good article on using the Multithreaded options.

Also add the /FFT option if backing up to a NAS to avoid re-copy due to timestamp rounding.

Updated: Tuesday 29th May 2012, 12:53pm

There are 0 comments

Leave a comment of your own

Comments are currently closed.