1. Home
  2. File Server Migration

File Server Migration

Recently we ran into an issue where we discovered that our file server shares were being run directly off the C: drive. This is a huge issue because as Windows hosts run out of disk space they begin to slow down drastically.

Our resolution for this issue was to add another disk to the machine and copy the shared data over to the new disk. Early on we ran into the issue where more than half of our files wouldn’t copy due to permissions issues with our robocopy command. After spending a good chink of time understanding robocopy better, this is the command that ended up solving all our issues:

robocopy "C:\SHARED" "M:\SHARED" /E /B /MIR /XO /r:2 /w:3 /copyall /log:M:\ROBOCOPY-Logs\SHARED.log /V /NP

robocopy "C:\SHARED" "M:\SHARED" /E /B /MIR /XO /r:2 /w:3 /copyall /log:M:\ROBOCOPY-Logs\Last-Copy\SHARED.log /V /NP

get-content 'M:\ROBOCOPY-Logs\SHARED.log' -Tail 0 -Wait

The first command is our first run of the command and it outputs the results of the copy on the M: drive in the shared log file. After running this command, I restarted all machines that connect to this file server as well as the file server itself to clear all locks on files.

The second command does the same thing as the first machine, however it creates a new log file that shows what was copied the second time around as well as if anything was missed.

The third command is a PowerShell command that allows you to view the log file in real time as the first two commands were running.

Explanation of the above robocopy command:

  • /E – Copy subfolders including empty subfolders
  • /B – Copy files in backup mode
  • /MIR – Mirror a directory tree
  • /XO – If destination file exists and is the same date or newer than the source, don’t overwrite
  • /r:2 – Number of retries on failed copies
  • /w:3 – Wait time between retries
  • /copyall – Copy ALL file info. This will prevent dehydrating offline files and will instead copy the file’s tag (on emc VNX/Unity systems at least). This is not officially documented! If dehydration is what you need (reason i found this issue), you can’t copy the ACLs along your files.
  • /log:M:\ROBOCOPY-Logs\SHARED.log – Output status to log file and overwrite
  • /V – Produce verbose output log, showing skipped files
  • /NP – No progress. Suppresses the display of progress information. This can be useful when output is redirected to a file.

Leave a Comment