Migration with robocopy (Windows)

With robocopy (Robust File Copy) you can transfer files and folders from one Windows server to another over a network share — reliably, with automatic retries on failure.

Prerequisites: RDP access to the source server. The target server needs a network share or a jointly accessible network drive. robocopy is pre-installed on Windows Server 2008 R2 and later.

robocopy parameters for migration

ParameterPurpose
/ECopies all subdirectories including empty folders
/COPYALLCopies all file attributes: data, attributes, timestamps, ACLs, owner
/MIRMirrors the source directory — deletes files on the target that no longer exist on the source
/R:33 retry attempts on failure
/W:1010 second wait between retries
/LOGWrites 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 "Everyone"

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.