Search This Blog

Robocopy Command Examples

In my previous post, I summarize some key information about Robocopy. In this post, I will share some Robocopy command examples that I have used in the file migration projects. Even these examples have been successfully used on the production environment, please verify yourself before use. That is why I add the /L option on all the examples. Save the following to a batch file and pick the command by remove the rem at the beginning of the line.

@echo off

set LOG_FILE="C:\Temp\ROBOCOPY_LOG.TXT"
set SOURCE="Source Path"
set DEST="Destination Path"

rem Remove rem on the command line you want to run
rem Only one Robocopy command line is used at a time
rem Remove /L to apply the change after confirm the outcome in the log file

rem *************************************************
rem /PURGE option
rem Mirror the source to the destination - the newer file in the destination will be overwritten, the extra file in the destination will be purged
rem robocopy %SOURCE% %DEST% /E /COPYALL /PURGE /MT /R:1 /W:1 /V /NP /TEE /LOG+:%LOG_FILE% /L

rem /ZB option
rem Use /ZB option when file cannot be copied
rem robocopy %SOURCE% %DEST% /E /ZB /COPYALL /PURGE /MT /R:1 /W:1 /V /NP /TEE /LOG+:%LOG_FILE% /L

rem *************************************************
rem default option - changed, newer, and older file is copied; extra file is not impacted
rem Copy the source to the destination - the newer file in the destination will be overwritten, but keep the extra file in the destination
rem robocopy %SOURCE% %DEST% /E /COPYALL /MT /R:1 /W:1 /V /NP /TEE /LOG+:%LOG_FILE% /L

rem *************************************************
rem /XO option
rem Copy the source to the destination - keep the newer file and extra file in the destination
rem robocopy %SOURCE% %DEST% /E /COPYALL /MT /R:1 /W:1 /V /NP /TEE /LOG+:%LOG_FILE% /XO /L

rem *************************************************
rem /FFT option
rem Copy the source to the destination - when the third-party storage system is used
rem robocopy %SOURCE% %DEST% /E /COPYALL /MT /R:1 /W:1 /V /NP /TEE /LOG+:%LOG_FILE% /FFT /L

No comments:

Post a Comment

Use WinSCP to Transfer Files in vCSA 6.7

This is a quick update on my previous post “ Use WinSCP to Transfer Files in vCSA 6.5 ”. When I try the same SFTP server setting in vCSA 6.7...