Migration with robocopy (Windows)
This guide shows how to transfer files and folders from one Windows Server to another with robocopy over a network share – with automatic retries on errors.
Prerequisites: RDP access to the source server. The target server needs a network share or a jointly accessible network drive. robocopy is included in Windows Server 2019, 2022 and 2025. Allow SMB (TCP port 445) in the target server's firewall for the source server's IP only.
robocopy parameters for migration
| Parameter | Purpose |
|---|---|
| /E | Copies all subdirectories including empty folders |
| /COPYALL | Copies all file attributes: data, attributes, timestamps, ACLs, owner |
| /MIR | Mirrors the source directory — deletes files on the target that no longer exist on the source |
| /R:3 | 3 retry attempts on failure |
| /W:10 | 10 second wait between retries |
| /LOG | Writes progress to a log file |
Step 1: Set up a network share on the target server
Create a shared folder on the target server that the source server can write to.
PowerShell
New-Item -ItemType Directory -Path "C:\Migration"
New-SmbShare -Name "MigrationShare" -Path "C:\Migration" -FullAccess "Administrator"
Remove the share after migration: Remove-SmbShare -Name "MigrationShare"
Step 2: Map the share on the source server
Connect the target server's share as a network drive on the source server.
PowerShell
net use Z: \\TARGET_SERVER_IP\MigrationShare /user:Administrator PASSWORD
Step 3: Transfer data
Run robocopy from the source server to the target share.
PowerShell
robocopy "C:\inetpub" "Z:\inetpub" /E /COPYALL /R:3 /W:10 /LOG:C:\migration.log
Repeat for all other directories you need to migrate (e.g. C:\Users, C:\ProgramData).
Step 4: Delta sync before switching
Run a second pass just before the DNS cutover to catch any changes since the first run.
PowerShell
robocopy "C:\inetpub" "Z:\inetpub" /E /COPYALL /MIR /R:3 /W:10 /LOG:C:\migration-delta.log
Step 5: Start services & test
Start all services on the target server and test applications before switching DNS.
1.Start IIS, SQL Server, and all other services on the target server
2.Test your applications via the target server's IP address
3.Remove the network share and update DNS records once everything works correctly
Further Documentation
For the full reference of all robocopy parameters, refer to the official Microsoft documentation.