This shows you how to copy data from one computer to another via the robocopy utility. Robocopy is a utility that is built into Windows.
There are many uses and options for robocopy. View Microsoft’s documentationhere for all the options.
In our use case, we’ll run the following robocopy command from the source computer.
robocopy f:\users \\dc1\e$\users /e /sec /r:0 /log:robolog.txt /tee
You can run it directly from command line or in a batch file so that it’s easier to run multiple times at different times.
NOTE: In our example, the destination computer is called DC1. Change it to your server name.
Let’s walk through what this does:
robocopy f:\users \\dc1\e$\users – It’ll copy all files and folders from f:\users to the users folder on the E drive on the destination computer.
/e – it’ll copy empty folders.
/sec – it’ll copy NTFS permissions.
/r:0 – it won’t retry failed copies.
/log:robolog.txt – It’ll save results to the same folder where you’re running robocopy from.
/tee – It’ll write progress to the screen in addition to the text file.
You can also use the /XD option to exlude a folder: /XD exclude-folder-1
You can run this multiple times against the same folders. The first time, it’ll copy everything. On subsequent times, it’ll copy new and changed files at the source to the destination. This is like running an initial ‘full’ and then subsequent ‘incrementals’ to grab changes. I use this all the time when migrating network shares. I’ll run it before the migration to grab everything and then again at the time of migration to grab new and changed files.
Using robocopy this way does not delete anything from the destination. This is important to know because that means if a file is copied from source to destination and then a user deletes it from the source, it will not delete it from the destination as well. There are ways to have robocopy do this, check the link above for Microsoft’s documentation on all the options available.
Another thing to note is that using robocopy in this way is one-way sync only. Data is only synced from source to destination and not visa-versa. Again, check Microsoft’s documentation on options to sync both ways (‘mirroring’).
Jason works as a project specialist at an IT MSP in Erie, Pennsylvania, USA. He’s an IT/security professional with 17 years experience.