• Use robocopy to switch file servers

    Home » Forums » Admin IT Lounge » Admin IT Lounge – Miscellaneous » Use robocopy to switch file servers

    Author
    Topic
    #493338

    Hi all. I have a massive file copy I need to do as I’m moving data from fileserver1 to fileserver2. There’s so much data, and it copies so slowly, that it will take possibly as long as 24 hours for the robocopy to complete. Also, there’s no way to keep the users out of the files while the copy is going on.

    Because of this I was wondering how I could use robocopy to get the job done. If I use the /MIR switch I know it will create an exact copy of what’s in fileserver1 and place it on fileserver2. Once that’s done I’d like to run another robocopy that only copies files that have changed since the last copy. I’d like to think that would result in a copy that would go very quickly. The only problem is I don’t know how to do that.

    Can robocopy do that? If so, how?

    Viewing 1 reply thread
    Author
    Replies
    • #1438606

      Robocopy is the answer to server migration. It needs to be done in 3 steps. 1st you copy the data – this can take several days. 2nd you update the data – copy new files and fix issues, usually permissions. Run step 2 overnight several times until you have fixed all the errors and are ready to go. 3rd you do a final update and apply permissions to the new server. I’ve attached the migration batch file I have used used for years.

      cheers, Paul

      Code:
      @echo off
      rem *****************************************************************************
      rem Script Robocopies the File Server files to a new Location
      rem 
      rem author 	: Lee
      rem .
      rem Edit History	: PT, added /NDL /NFL /NP to turn off file logging
      rem                         and progress indicator.
      rem                       Choose the required form of copy.
      rem                         Use create first, then schedule Update.
      rem                         Copy Security last.
      rem                       PT, added time and date to log file name.
      rem                       PT 7/2005, Added step numbers. Modified Copy security command.
      rem .
      rem Log File 		: 
      rem .
      rem *****************************************************************************
      
      REM CHANGE THIS to a new folder ; make sure there is enough space on the destination server.
      
      setlocal
      set Orig_Server=F:
      set Dest_server=\c$
      
      for /f “tokens=1,2 delims=: ” %%x in (“%time%”) do set EFtime=%%x%%y
      for /f “tokens=2-4 delims=/ ” %%x in (“%date%”) do set EFdate=%%z%%y%%x
      set errorfile=DataError%EFdate%%EFtime%.txt
      
      Rem Edit the file for whichever command you want to use. 
      Rem Use steps in order for efficient copying.
      
      
      Rem STEP 1 – RUN MANUALLY
      Rem Create file/directory structure only, do NOT copy security.
      Rem Prevents directory fragmentation and improves file system performance.
      Rem Verbose output.
      robocopy %Orig_Server% %Dest_server% /NDL /NFL /NP /S /E /COPY:DAT /CREATE /V /TEE /R:1 /W:1 /log+:%errorfile%
      
      
      Rem STEP 2 – SCHEDULE TO RUN NIGHTLY
      Rem Update, only copy files that are newer than the destination.
      Rem Delete files not in source.
      Rem Do NOT copy security.
      Rem Quiet, log summary and errors only.
      ::robocopy %Orig_Server% %Dest_server% /NDL /NFL /NP /MIR /COPY:DAT /TEE /R:1 /W:1 /log+:%errorfile%
      
      Rem STEP 3 – RUN MANUALLY AFTER THE LAST RUN OF STEP 2
      Rem Copy Security, ownership and auditing data only.
      Rem Quiet, log summary and errors only.
      ::robocopy %Orig_Server% %Dest_server% /NDL /NFL /NP /S /E /IS /COPY:SOU /TEE /R:1 /W:1 /log+:%errorfile%
      
      
      Rem ALTERNATE COMMAND – PERFORM ALL 3 STEPS AT ONCE
      
      Rem Copy all data including security, delete files not in source.
      Rem Verbose output.
      rem robocopy %Orig_Server% %Dest_server% /MIR /COPYALL /ETA /V /TEE /R:1 /W:1 /log:%errorfile%
      
      
      Rem errorlevel checking
      
      if errorlevel 16  echo ERROR: ***FATAL ERROR***  >>%errorfile% & goto end
      if errorlevel 15  echo ERROR: FAIL MISM XTRA COPY >>%errorfile% & goto end
      if errorlevel 14  echo ERROR: FAIL MISM XTRA      >>%errorfile% & goto end
      if errorlevel 13  echo ERROR: FAIL MISM      COPY >>%errorfile% & goto end
      if errorlevel 12  echo ERROR: FAIL MISM           >>%errorfile% & goto end
      if errorlevel 11  echo ERROR: FAIL      XTRA COPY >>%errorfile% & goto end
      if errorlevel 10  echo ERROR: FAIL      XTRA      >>%errorfile% & goto end
      if errorlevel  9  echo ERROR: FAIL           COPY >>%errorfile% & goto end
      if errorlevel  8  echo ERROR: FAIL                >>%errorfile% & goto end
      if errorlevel  7  echo ERROR:      MISM XTRA COPY >>%errorfile% & goto end
      if errorlevel  6  echo ERROR:      MISM XTRA      >>%errorfile% & goto end
      if errorlevel  5  echo ERROR:      MISM      COPY >>%errorfile% & goto end
      if errorlevel  4  echo ERROR:      MISM           >>%errorfile% & goto end
      if errorlevel  3  echo ERROR:           XTRA COPY >>%errorfile% & goto end
      if errorlevel  2  echo ERROR:           XTRA      >>%errorfile% & goto end
      if errorlevel  1  echo * SUCCESSFUL COPY * >>%errorfile% & goto end
      if errorlevel  0  echo Notice:    –no change, no data copied–    >>%errorfile% & goto end
      :end
      
    • #1439904

      The last move I did I used Microsoft Sync. It will do either one-way or two-way sync.

      http://www.microsoft.com/en-us/download/details.aspx?id=15155.

      It allowed me to keep the two servers in sync during the transition from one server to the other.

    Viewing 1 reply thread
    Reply To: Use robocopy to switch file servers

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: