SMCC Logo and link to www.smccm.edu

 
 

Howard Burpee, Professor, Computer Technology, 207.741.5527, howardburpee@ctech.smccme.edu

 


 

 

 

 

How-to use Robocopy to synchronize files between two systems

CPT 203 - T1  Graphic Operating Systems  Presentation Project. 

Ima T. Geek

What is Robocopy?

Robocopy is a command that is used at the command line to make copies of files and folders. It is also known as Robust File Copy. It comes with windows vista, but was also part of the windows resource kit. It was made to be used for mirroring directories. Robocopy has the same abilities as more familiar commands such as copy and xcopy, the biggest difference is that its not a file copier, it was made to copy folders and keep them in the same form as they were. 

What are the benefits of using Robocopy over copy or xcopy?

  • Robocopy when "synching" will only copy a file if the file it is being compared to has either a different file size or time stamp, so as to not waste time copying the same exact file.
  • Robocopy has the ability to delete source files after copying them in other words move the files rather then copy.
  • Robocopy can be scheduled so that it can copy whenever you need it to not the moment you run the command.
  • Robocopy also works over network connections so you can now copy over a network easily. It also has the ability to pick up where it left off if its disconnected which means when a copy fails at 99% you can just finish the last bits that were not copied.

What are the requirements for using Robocopy?

Robocopy requires one of the following Operating Systems: Microsoft Vista, Microsoft Windows Server 2008, Microsoft Windows Server 2003, Microsoft Windows XP, Microsoft Windows 2000 or Microsoft Windows NT version 4.0. 

Who uses Robocopy?

Robocopy is more often used by IT professionals but is easy enough to use for the average home user. In the office IT would use it for synchronizing servers and other back ups where the home user may use it to copy some personal items such as pictures or music to their preferred storage location. Robocopy will allow you to copy anywhere the computer has access to; Local Drives, Removable Drives, Over the local area network, even across the world to different remote locations.

Examples of some of the syntax that would be used in Robocopy:

Here is the basic line that you would use in a variable format if you were to run Robocopy:

Robocopy source destination [File [file] ... ] [options]

Variable

Meaning

Comments

source

Source directory

You can use drive:\path or \\server\share\path

destination

Destination directory

You can use drive:\path or \\server\share\path

file

Names of files to act upon

You can use wildcard characters (? and *). If no files are listed, Robocopy defaults to all files (*.*).

options

Command-line options you wish to use

Available options are described later in this document.

(Slu)

Examples of different commands that you could run:

Robocopy c:\sales c:\salesbu *.xls /mon:1 /r:2000

This example shows that I am taking my excel spread sheets from my local sales folder and backing them up to a folder called salesbu. I have set this run of robocopy to monitor the files so that whenever there is a change with it, it will copy it to the backup location. I have set the monitoring to 1 so that it is resaved every time a changes is made, but you could set it to any number of changes before it would resave. I have also had it set to retry up 2000 times before it quits if it can not immediately copy them. 

For my example I created a spread sheet called "sales.xls" you can see above that it took directory I was storing my sheet in and copied it and the file inside of it. You can also see that after it finished its copy it gave me a status of the monitor at the bottom of the screen. This program will monitor until I end it so you can always have a constant backup going if that is what you are going for. You can see that it had waited for a minute and then I made a change in the sheet in excel and once I saved it, it knew there was a change due to the new timestamp of the file.

Here you can see that it has again copied the files over but this time it skipped the directory since that had not changed. This would happen any time anyone entered info into the sheet and saved it.

 

Robocopy \\terastation\share\sales c:\oldcopy /mir

This example shows that I am going to mirror the files and folders from the terastation to my local PC. When I use the /mir option it copies all subdirectories even empty ones, and it removes anything in my destination folder that isn't from the source folder on terastation. The computer would need to have access to terastation already for this command to work over the network.

Switches and what they are:

Copy options :

                 /S :: copy Subdirectories, but not empty ones.
                 /E :: copy subdirectories, including Empty ones.
             /LEV:n :: only copy the top n LEVels of the source directory tree.

                 /Z :: copy files in restartable mode.
                 /B :: copy files in Backup mode.
                /ZB :: use restartable mode; if access denied use Backup mode.
            /EFSRAW :: copy all encrypted files in EFS RAW mode.

  /COPY:copyflag[s] :: what to COPY for files (default is /COPY:DAT).
                       (copyflags : D=Data, A=Attributes, T=Timestamps).
                       (S=Security=NTFS ACLs, O=Owner info, U=aUditing info).

           /DCOPY:T :: COPY Directory Timestamps.

               /SEC :: copy files with SECurity (equivalent to /COPY:DATS).
           /COPYALL :: COPY ALL file info (equivalent to /COPY:DATSOU).
            /NOCOPY :: COPY NO file info (useful with /PURGE).

            /SECFIX :: FIX file SECurity on all files, even skipped files.
            /TIMFIX :: FIX file TIMes on all files, even skipped files.

             /PURGE :: delete dest files/dirs that no longer exist in source.
               /MIR :: MIRror a directory tree (equivalent to /E plus /PURGE).

               /MOV :: MOVe files (delete from source after copying).
              /MOVE :: MOVE files AND dirs (delete from source after copying).

     /A+:[RASHCNET] :: add the given Attributes to copied files.
     /A-:[RASHCNET] :: remove the given Attributes from copied files.

            /CREATE :: CREATE directory tree and zero-length files only.
               /FAT :: create destination files using 8.3 FAT file names only.
               /256 :: turn off very long path (> 256 characters) support.

             /MON:n :: MONitor source; run again when more than n changes seen.
             /MOT:m :: MOnitor source; run again in m minutes Time, if changed.

      /RH:hhmm-hhmm :: Run Hours - times when new copies may be started.
                /PF :: check run hours on a Per File (not per pass) basis.

             /IPG:n :: Inter-Packet Gap (ms), to free bandwidth on slow lines.

                 /SL:: copy symbolic links versus the target.

File Selection Options :

                 /A :: copy only files with the Archive attribute set.
                 /M :: copy only files with the Archive attribute and reset it.
    /IA:[RASHCNETO] :: Include only files with any of the given Attributes set.
    /XA:[RASHCNETO] :: eXclude files with any of the given Attributes set.

 /XF file [file]... :: eXclude Files matching given names/paths/wildcards.
 /XD dirs [dirs]... :: eXclude Directories matching given names/paths.

                /XC :: eXclude Changed files.
                /XN :: eXclude Newer files.
                /XO :: eXclude Older files.
                /XX :: eXclude eXtra files and directories.
                /XL :: eXclude Lonely files and directories.
                /IS :: Include Same files.
                /IT :: Include Tweaked files.

             /MAX:n :: MAXimum file size - exclude files bigger than n bytes.
             /MIN:n :: MINimum file size - exclude files smaller than n bytes.

          /MAXAGE:n :: MAXimum file AGE - exclude files older than n days/date.
          /MINAGE:n :: MINimum file AGE - exclude files newer than n days/date.
          /MAXLAD:n :: MAXimum Last Access Date - exclude files unused since n.
          /MINLAD:n :: MINimum Last Access Date - exclude files used since n.
                       (If n < 1900 then n = n days, else n = YYYYMMDD date).

                /XJ :: eXclude Junction points. (normally included by default).

               /FFT :: assume FAT File Times (2-second granularity).
               /DST :: compensate for one-hour DST time differences.

               /XJD :: eXclude Junction points for Directories.
               /XJF :: eXclude Junction points for Files.

Retry Options :

               /R:n :: number of Retries on failed copies: default 1 million.
               /W:n :: Wait time between retries: default is 30 seconds.

               /REG :: Save /R:n and /W:n in the Registry as default settings.

               /TBD :: wait for sharenames To Be Defined (retry error 67).

Logging Options :

                 /L :: List only - don't copy, timestamp or delete any files.
                 /X :: report all eXtra files, not just those selected.
                 /V :: produce Verbose output, showing skipped files.
                /TS :: include source file Time Stamps in the output.
                /FP :: include Full Pathname of files in the output.
             /BYTES :: Print sizes as bytes.

                /NS :: No Size - don't log file sizes.
                /NC :: No Class - don't log file classes.
               /NFL :: No File List - don't log file names.
               /NDL :: No Directory List - don't log directory names.

                /NP :: No Progress - don't display % copied.
               /ETA :: show Estimated Time of Arrival of copied files.

          /LOG:file :: output status to LOG file (overwrite existing log).
         /LOG+:file :: output status to LOG file (append to existing log).

       /UNILOG:file :: output status to LOG file as UNICODE (overwrite existing log).
      /UNILOG+:file :: output status to LOG file as UNICODE (append to existing log).

               /TEE :: output to console window, as well as the log file.

               /NJH :: No Job Header.
               /NJS :: No Job Summary.

           /UNICODE :: output status as UNICODE.


Job Options :

       /JOB:jobname :: take parameters from the named JOB file.
      /SAVE:jobname :: SAVE parameters to the named job file
              /QUIT :: QUIT after processing command line (to view parameters). 
              /NOSD :: NO Source Directory is specified.
              /NODD :: NO Destination Directory is specified.
                /IF :: Include the following Files.

(Robocopy: Robust File Copy)

 

Bibliography

"Robocopy." Wikipedia. Wikipedia.org. <http://en.wikipedia.org/wiki/Robocopy>.

Slu, http://www.stevelu.com/TechnicalArticles/DevTools/1206.aspx. 21 AUG 2004. 9 Dec 2008 <http://www.stevelu.com/TechnicalArticles/DevTools/1206.aspx>. 

"Robocopy: Robust File Copy." atlex.nl. 29 June 2008. 9 Dec 2008 <http://atlex.nl/tmp/robocopy_switches.txt>.

©Ima T. Geek, 2008

 


 

Acceptable Use Policy               Privacy Policy

 

© Copyright 1999 - 2014, Howard Burpee, All rights Reserved.  
For problems or questions regarding this web contact the Webmaster.
Various pages on this website were last updated on  June 09, 2014

Southern Maine Community College is an equal opportunity/affirmative action
institution and employer. For more information, please call 207.741.5798.