I was given a task to backup some data from some Windows computers to a local NAS drive. There are many options out there, but I remembered I many years ago I used a tool called Robocopy. As usual, Windows eventually bought this company and now Robocopy is part of Windows command tools.

Open your command prompt in Windows and type robocopy just to verify. You should see a brief output telling you about robocopy.

robocopy output in command prompt Windows

Now that you made sure robocopy is available in your Windows computer we can put this little script together maybe with a great cup of coffee on your desk. I will go directly to it:

@echo off 
robocopy C:\Users\%username%\Desktop\  \\hqnas01\home\migrated_data\Desktop /MIR /XA:H /R:1 /XA:SH /FFT /XJ > C:\temp\%username%_migration.log


C:\Users\%username%\Desktop\Source directory.
\\hqnas01\home\migrated_data\DesktopDestination directory.
/MIRMake a mirror backup. If you delete something from the source, it will also be deleted in the destination.
/XA:HLeave out hidden files.
/R:1The number of retries if the file is locked.
/XA:SHLeave out hidden files and system files.
/FFTThis is very important when backing up to a Linux NAS. If you leave this out it will try to copy files over and over even when they are already present. Just use it!
/XJExclude junction points. Those crazy hidden My Music, My Pictures and My Videos folders under Documents.
> C:\temp\%username%_migration.logFor creating a .log file in order to see what happened. If you’re adding more than one line of backup locations you should add ‘>>’ instead of ‘>’ so you can append to the .log instead of replacing what you had before.
robocopy example with explanation

Make sure you don’t confuse source with destination or you can have catastrophic lost of data. Contact me if you have any questions. Check out my shop with cool T-shirts and mugs designed by myself.

Leave a comment

Your email address will not be published. Required fields are marked *