File Explorer is fine for a few files. For a large folder, for a copy to another disk every night or for a copy that must survive an interruption, Windows has Robocopy. It copies only what is missing or has changed, so a second run continues where the first one stopped. This guide shows the commands you need and how to read the result.
The examples use Windows Server 2025 and copy the folder C:\Data to D:\Backup. Run the commands in PowerShell as Administrator: right-click the Start button and choose Terminal (Admin).
1. See First What Would Be Copied
With /L Robocopy only lists what it would do. Nothing is copied yet:
robocopy C:\Data D:\Backup /E /L
New Dir 1 C:\Data\ New File 7 notes.txt New Dir 0 C:\Data\Empty\ New Dir 3 C:\Data\Photos\ New File 200000 photo1.jpg New File 400000 photo2.jpg New File 600000 photo3.jpg
2. Copy the Folder
robocopy C:\Data D:\Backup /E /R:2 /W:5 /NP
/Ecopies all folders inside, also empty ones. The folderD:\Backupis created if it does not exist./R:2 /W:5tries a file that cannot be read two more times, 5 seconds apart, and then goes on. Without these, Robocopy tries a million times with 30 seconds between the tries, and one locked file holds up the whole copy./NPleaves out the percent counter of each file.
At the end Robocopy prints a summary:
Total Copied Skipped Mismatch FAILED Extras
Dirs : 3 3 0 0 0 0
Files : 4 4 0 0 0 0
Bytes : 1.14 m 1.14 m 0 0 0 0
Copied is what was written now, Skipped what was already there and unchanged. FAILED must be 0; if it is not, scroll up to see which files could not be copied.
3. Run It Again to Continue or to Update
Run the same command again after an interruption, or the next day. Robocopy compares both sides and copies only new and changed files. When nothing changed, everything is skipped:
Total Copied Skipped Mismatch FAILED Extras
Dirs : 3 0 3 0 0 0
Files : 4 0 4 0 0 0
Bytes : 1.14 m 0 1.14 m 0 0 0
4. Keep Both Sides the Same: /MIR
With /E, a file that you delete in C:\Data stays in the copy. /MIR makes the copy an exact mirror: it also deletes from D:\Backup what is no longer in C:\Data.
robocopy C:\Data D:\Backup /MIR /R:2 /W:5 /NP
New File 5 C:\Data\new.txt *EXTRA File 600000 D:\Backup\Photos\photo3.jpg
*EXTRA File marks a file that exists only in the copy; /MIR deletes it.
Everything in the second folder that is not in the first one is deleted. If you swap the two folders, or name a folder that holds other data, that data is gone. Run the command with /L first and read the list.
5. Write the Result Into a File
robocopy C:\Data D:\Backup /E /R:2 /W:5 /NP /LOG:C:\Scripts\copy.log
The list and the summary then go into the file and not to the screen. This is what you want for a copy that runs by itself at night. The folder for the log, here C:\Scripts, must exist.
6. Run It Every Night
Create a task as shown in Run a Program or Script on a Schedule on Windows Server: Task Scheduler, with robocopy.exe as the program and the rest of the line from step 5 as its arguments. Read the result of the task with this table:
| Result | What it means |
|---|---|
0 | Nothing had to be copied. |
1 | Files were copied. This is a success, not an error. |
2 or 3 | The copy holds extra files that are not in the source; with 3, files were copied as well. |
8 or more | Some files could not be copied. Read the log. |
16 | Nothing was copied, for example because the source folder does not exist. |
Good to Know
- A wrong source folder gives
ERROR 2 (0x00000002) Accessing Source DirectoryandThe system cannot find the file specified. Check the path. - A copy on another disk of the same server protects you from a failed disk, but not from the loss of the server. Keep important data in a second place as well: Back Up Windows Server With Windows Server Backup and Transfer Files to Windows Server With SFTP.
- Additional disks: How to Use Additional Disks on Windows Server.
