Robocopy

Ever experienced a Microsoft Windows file copy drop half way through? Skipped files? Filename too long? Windows Robocopy has been around for many years but a lot of people simply don’t know it exists. With an extensive syntax it is a great command line tool.

Robocopy is a free download from Microsoft and included in the later server operating systems (at time of writing). For those naughty people still on Windows 2003 it is included in the Windows 2003 Resource Kit, which can be located here. If in doubt simply head over to your command prompt and type Robocopy /? which should display your list of syntax options available for you to use.

Today we are going to talk about the common occurrence, a Windows GUI file copy that fails half way through, skips files, complains of filenames that are too long – the list goes on. In fact I no longer use Windows GUI for copying a large batch of files and always revert to Robocopy. So what can you do if you have used the Windows GUI to copy hundreds of gigs of data and find that at the end there is a ton of complaints from Windows. Start writing them all down? Print screen every error? NO! Robocopy to the rescue.

Next the small print. I can take no responsibility for your usage of this tool or following this guide. If in doubt, contact us for professional advice.

So with all copies you will of course have your source folder (being the location where you want to copy from) and your destination location (where you would like your files to be copied to). Be aware that this will see ANY changed files and overwrite the destination. Be very careful if users are working on the new location and the files there are being changed. If for example someone has deleted the file at the destination, this will be recopied. Also be very aware of the PURGE switch, if you have for example removed the files from your source location these too will be removed from your destination!

In our example we are going to SYNC all files and folders from C:Data to a new folder on a new server newserverdata:

C:>robocopy “C:Data” “newserverdata” /E /ZB /X /PURGE /COPYALL /TEE /LOG:C:DaraRobocopy-data-to-newdata.log

/E :: copy subdirectories, including Empty ones.
/ZB :: use restartable mode; if access denied use Backup mode.
/COPYALL :: COPY ALL file info (equivalent to /COPY:DATSOU).
/PURGE :: delete dest files/dirs that no longer exist in source.
/X :: report all eXtra files, not just those selected.
/TEE :: output to console window, as well as the log file.
/LOG:file :: output status to LOG file (overwrite existing log).

Remember one GOLDEN RULE. Ensure good backups of your SOURCE data before migrating any server data.

If you require any professional assistance on this or any other IT related procedure, please feel free to contact us.