# Robust File Copy for Windows

Recently I had a problem with the file media server when one of the disk in disk array is down. In this case every server degrade the own disk speed, cause it has to recover the data from the broken one. The problem was that I have thousands of important files (>1Gb) there which I can’t allow to lose. Disk rebuild is risky cause if during rebuild process the second hard drive down - you may lose your data very easy. The server and clients working on Windows platform. If I start save material to the local hard drives by Windows copy I get Windows error, cause transmission interrupted by server frequently. Other side I want to be sure that my local copy reflect the files location on the server.

I remembered that there is a good program for such purposes on every Windows system which calls Robocopy. It saved my days.

Robocopy, or Robust File Copy, is a command-line directory and/or file replication utility. Robocopy functionally replaces Xcopy, with more options. It has been available as part of the Windows Resource Kit starting with Windows NT 4.0, and was first introduced as a standard feature in Windows Vista and Windows Server 2008.”

The advantages of this Microsoft program that it allows mirror the files and resume copy of broken connections. Ability to tolerate network interruptions and resume copying is main feature for me. (Incomplete files are marked with a date stamp of 1970-01-01 and contain a recovery record so Robocopy knows where to continue from). Robocopy does not copy open files. Even Robocopy’s Backup mode will not touch those files. Therefore, Robocopy is not useful for backing up live operating system volumes. Also Robocopy’s “inter-packet gap” (IPG) option allows some control over the network bandwidth used in a session cause broken file server slow down connections.

Below I’ll give you some useful keys for this program. I used this in my PowerShell script to automate my tasks:

PS C:\> Robocopy SrcPath DestPath /MIR /Z /XJ /FFT /IPG:30 /R:13 /TEE
This example resume connection of large files and make a mirror. IPG gives delay in 30 milliseconds and Z is resume option. R means how much retries you need before pass. The R option gives you possibility to postpone download of large files and copy all small ones. Please keep attention to SrcPath DestPath. IF YOU GIVE THE WRONG DIRECTION THE MIRROR FUNCTION ERASE ALL YOUR FILES!

This example enable multithreaded copying for fast connections:

PS C:\> Robocopy SourcePath DestPath /MIR /XJ /FFT /MT /R:7 /TEE

The last example DO NOTHING, just shows you what will be DONE (L option). Very useful to check if your mirroring direction is correct:

PS C:\> Robocopy SourcePath DestPath /MIR /XJ /FFT /R:7 /TEE /L

Have a good day…