One of the Best tool for Migration - Robocopy

We all know or heard about the Robocopy being an amazing tool during migration or copying data. In this post i just want to talk about few of the Flags of Robocopy that i have used couple of times as per the situation. We have used Robocopy to migrate File share or during differential Run or so many other aspects where Robocopy is a life savior.

Now without wasting time below is the simplest command ever :

Open command prompt in Administrator and type below command :

robocopy <source> <Destination>  /Mir

now just like /Mir there are so many flags that we use /Mir would mirror source and destination. That means if something there on destination but not present on the source in that case it would erase it as well so be cautious before using it.


Now if there is a scenario where you need to copy the permissions as well along with the data in that case we use /Sec flag as shown below :

robocopy <source> <Destination>  /Mir  /Sec


Now sometimes what happened your robocopy get stuck either because you dont have permission on the particular files or that file cant be copy stuck or in use. In that scenario rather wasting time on re-tries use w:0 and r:0 flag to skip if unable to copy due to any reason.


robocopy <source> <Destination>  /Mir  /Sec  /w:0  /r:0


Now if you want the logs of the Robocopy run so that if something goes wrong you can check there. You need to provide the log flag along with the location of the logs and if you want status on console window as well as on log then use /Tee flag

robocopy <source> <Destination>  /Mir  /Sec  /w:0  /r:0  /log:c:\Logs\xyz.log  /tee


Now the situation is you need to exclude some directory then you can use /XD flag and this would help you alot because in most cases you will find backup folders which are keep on updating or any folders like that , you should exclude else robocopy would stuck in loop. Happened with me where source was 3TB but robocopy copied 3.5TB and still running - after digging deep we found the snapshot folder which was keep on updating or changing.
  

 robocopy <source> <Destination>  /Mir  /Sec  /w:0  /r:0  /log:c:\Logs\xyz.log  /tee   /XD “\\xyz\abc\~snapshot


As per migration respective, i have discussed few flags and commands of robocopy however if you have a different requirement then you can dig here 



https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/robocopy



No comments:

Post a Comment

MS Defenders

 Microsoft Defender offers a wide range of security solutions, similar to the ones we've discussed (Defender for Containers, Defender fo...