Robocopy - a Unix 'rsync' equivalent.txt - Notepad

Robocopy - a Unix 'rsync' equivalent

The script below copies data from FileServ1 to FileServ2, the destination holds a full mirror along with file security info. When run regularly to synchronize the source and destination, robocopy will only copy those files that have changed (change in time stamp or size).

Note: this script is not specific to PowerShell. It can be run in command prompt. Robocopy started off as an external program, but is now included in Windows 7 and more modern Windows operating systems.


@ECHO OFF

SETLOCAL

SET _source=\\FileServ1\e$\users

SET _dest=\\FileServ2\e$\BackupUsers

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:MyLogfile.txt /NFL /NDL

:: /R:n :: number of Retries

:: /W:n :: Wait time between retries

:: /LOG :: Output log file

:: /NFL :: No file logging

:: /NDL :: No dir logging

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


Note, change to the below line to not copy NTFS permissions:
SET _what=/COPY:DAT /B /MIR

Source

Back