Lapas

ceturtdiena, 2016. gada 17. novembris

Copy data to other location and retain permissions

@echo off

SET SRC="\\server\share"
SET DST="C:\WHERE YOU WANT FILES TO GO"
SET LOG="C:\Robocopy.log"

ROBOCOPY %SRC% %DST% /E /ZB /MIR /SEC /SECFIX /COPYALL /R:1 /W:1 /V /TEE /LOG:%LOG%
@if errorlevel 16 echo ***ERROR *** & goto END
@if errorlevel 8  echo **FAILED COPY ** & goto END
@if errorlevel 4  echo *MISMATCHES *      & goto END
@if errorlevel 2  echo EXTRA FILES       & goto END
@if errorlevel 1  echo --Copy Successful--  & goto END
@if errorlevel 0  echo --Copy Successful--  & goto END
goto END

:END

PAUSE


Here's what the switches mean:
  • SRC:: Source Directory (drive:\path or \\server\share\path).
  • DST:: Destination Dir  (drive:\path or \\server\share\path).
  • /E :: copy subdirectories, including Empty ones.
  • /ZB :: use restartable mode; if access denied use Backup mode.
  • /MIR :: Mirrors a directory tree.
  • /SEC :: Copies files with security
  • /SECFIX ::Fixes file security on all files, even skipped ones.
  • /COPYALL :: COPY ALL file info (equivalent to /COPY:DATSOU).  Copies the Data, Attributes, Timestamps, Owner, Permissions and Auditing info
  • /R:n :: number of Retries on failed copies: default is 1 million but I set this to only retry once.
  • /W:n :: Wait time between retries: default is 30 seconds but I set this to 1 second.
  • /V :: produce Verbose output, showing skipped files.
  • /TEE :: output to console window, as well as the log file.
  • /LOG:file :: output status to LOG file (overwrite existing log).
Source: community.spiceworks.com

Nav komentāru:

Ierakstīt komentāru